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

Commit90cf4d7

Browse files
committed
Fix new PermissionError in Windows with Python 3.7
In Python 3.7, tempfile.TemporaryDirectory doesn't delete files oncleanup whose permissions have to be changed to be deleted.This uses `@with_rw_directory` instead, though that may be overkillhere.
1 parentdd42e38 commit90cf4d7

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

‎test/test_tree.py

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
importos.pathasosp
88
frompathlibimportPath
99
importsubprocess
10-
importtempfile
1110

1211
fromgit.objectsimportTree,Blob
1312
fromgit.utilimportcwd
14-
fromtest.libimportTestBase
13+
fromtest.libimportTestBase,with_rw_directory
1514

1615

1716
classTestTree(TestBase):
@@ -43,36 +42,35 @@ def test_serializable(self):
4342
testtree._deserialize(stream)
4443
# END for each item in tree
4544

46-
@staticmethod
47-
def_get_git_ordered_files():
45+
@with_rw_directory
46+
def_get_git_ordered_files(self,rw_dir):
4847
"""Get files as git orders them, to compare in test_tree_modifier_ordering."""
49-
withtempfile.TemporaryDirectory()astdir:
50-
# Create directory contents.
51-
Path(tdir,"file").mkdir()
52-
forfilenamein (
53-
"bin",
54-
"bin.d",
55-
"file.to",
56-
"file.toml",
57-
"file.toml.bin",
58-
"file0",
59-
):
60-
Path(tdir,filename).touch()
61-
Path(tdir,"file","a").touch()
62-
63-
withcwd(tdir):
64-
# Prepare the repository.
65-
subprocess.run(["git","init","-q"],check=True)
66-
subprocess.run(["git","add","."],check=True)
67-
subprocess.run(["git","commit","-m","c1"],check=True)
68-
69-
# Get git output from which an ordered file list can be parsed.
70-
rev_parse_command= ["git","rev-parse","HEAD^{tree}"]
71-
tree_hash=subprocess.check_output(rev_parse_command).decode().strip()
72-
cat_file_command= ["git","cat-file","-p",tree_hash]
73-
cat_file_output=subprocess.check_output(cat_file_command).decode()
74-
75-
return [line.split()[-1]forlineincat_file_output.split("\n")ifline]
48+
# Create directory contents.
49+
Path(rw_dir,"file").mkdir()
50+
forfilenamein (
51+
"bin",
52+
"bin.d",
53+
"file.to",
54+
"file.toml",
55+
"file.toml.bin",
56+
"file0",
57+
):
58+
Path(rw_dir,filename).touch()
59+
Path(rw_dir,"file","a").touch()
60+
61+
withcwd(rw_dir):
62+
# Prepare the repository.
63+
subprocess.run(["git","init","-q"],check=True)
64+
subprocess.run(["git","add","."],check=True)
65+
subprocess.run(["git","commit","-m","c1"],check=True)
66+
67+
# Get git output from which an ordered file list can be parsed.
68+
rev_parse_command= ["git","rev-parse","HEAD^{tree}"]
69+
tree_hash=subprocess.check_output(rev_parse_command).decode().strip()
70+
cat_file_command= ["git","cat-file","-p",tree_hash]
71+
cat_file_output=subprocess.check_output(cat_file_command).decode()
72+
73+
return [line.split()[-1]forlineincat_file_output.split("\n")ifline]
7674

7775
deftest_tree_modifier_ordering(self):
7876
"""TreeModifier.set_done() sorts files in the same order git does."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp