Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Keep temp files out of project dir and improve cleanup#1825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 4 commits intogitpython-developers:mainfromEliahKagan:tree-test
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletiontest/lib/helper.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,7 +97,8 @@ def wrapper(self, *args, **kwargs):
returnfunc(self,path,*args,**kwargs)
exceptException:
_logger.info(
"Test %s.%s failed, output is at %r\n",
"%s %s.%s failed, output is at %r\n",
"Test"iffunc.__name__.startswith("test_")else"Helper",
type(self).__name__,
func.__name__,
path,
Expand Down
62 changes: 35 additions & 27 deletionstest/test_tree.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,14 +4,14 @@
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

fromioimportBytesIO

fromgit.objectsimportTree,Blob
fromtest.libimportTestBase

importos
importos.pathasosp
frompathlibimportPath
importsubprocess

fromgit.objectsimportTree,Blob
fromgit.utilimportcwd
fromtest.libimportTestBase,with_rw_directory


classTestTree(TestBase):
deftest_serializable(self):
Expand DownExpand Up@@ -42,28 +42,39 @@ def test_serializable(self):
testtree._deserialize(stream)
# END for each item in tree

deftest_tree_modifier_ordering(self):
defsetup_git_repository_and_get_ordered_files():
os.mkdir("tmp")
os.chdir("tmp")
@with_rw_directory
def_get_git_ordered_files(self,rw_dir):
"""Get files as git orders them, to compare in test_tree_modifier_ordering."""
# Create directory contents.
Path(rw_dir,"file").mkdir()
forfilenamein (
"bin",
"bin.d",
"file.to",
"file.toml",
"file.toml.bin",
"file0",
):
Path(rw_dir,filename).touch()
Path(rw_dir,"file","a").touch()

withcwd(rw_dir):
# Prepare the repository.
subprocess.run(["git","init","-q"],check=True)
os.mkdir("file")
forfilenamein [
"bin",
"bin.d",
"file.to",
"file.toml",
"file.toml.bin",
"file0",
"file/a",
]:
open(filename,"a").close()

subprocess.run(["git","add","."],check=True)
subprocess.run(["git","commit","-m","c1"],check=True)
tree_hash=subprocess.check_output(["git","rev-parse","HEAD^{tree}"]).decode().strip()
cat_file_output=subprocess.check_output(["git","cat-file","-p",tree_hash]).decode()
return [line.split()[-1]forlineincat_file_output.split("\n")ifline]

# Get git output from which an ordered file list can be parsed.
rev_parse_command= ["git","rev-parse","HEAD^{tree}"]
tree_hash=subprocess.check_output(rev_parse_command).decode().strip()
cat_file_command= ["git","cat-file","-p",tree_hash]
cat_file_output=subprocess.check_output(cat_file_command).decode()

return [line.split()[-1]forlineincat_file_output.split("\n")ifline]

deftest_tree_modifier_ordering(self):
"""TreeModifier.set_done() sorts files in the same order git does."""
git_file_names_in_order=self._get_git_ordered_files()

hexsha="6c1faef799095f3990e9970bc2cb10aa0221cf9c"
roottree=self.rorepo.tree(hexsha)
Expand DownExpand Up@@ -92,9 +103,6 @@ def names_in_mod_cache():
here=file_names_in_order()
return [eforeinaifeinhere]

git_file_names_in_order=setup_git_repository_and_get_ordered_files()
os.chdir("..")

mod.set_done()
assertnames_in_mod_cache()==git_file_names_in_order,"set_done() performs git-sorting"

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp