Skip to content

Commit 4ad703b

Browse files
bmwiedemannserhiy-storchaka
authored andcommitted
bpo-30693: Fix tarfile test cleanup on MSWindows (#5557)
it was using our mocked listdir to check when the files were gone.
1 parent c1e46e9 commit 4ad703b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/test/test_tarfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,17 +1131,17 @@ def test_directory_size(self):
11311131

11321132
# mock the following:
11331133
# os.listdir: so we know that files are in the wrong order
1134-
@unittest.mock.patch('os.listdir')
1135-
def test_ordered_recursion(self, mock_listdir):
1134+
def test_ordered_recursion(self):
11361135
path = os.path.join(TEMPDIR, "directory")
11371136
os.mkdir(path)
11381137
open(os.path.join(path, "1"), "a").close()
11391138
open(os.path.join(path, "2"), "a").close()
1140-
mock_listdir.return_value = ["2", "1"]
11411139
try:
11421140
tar = tarfile.open(tmpname, self.mode)
11431141
try:
1144-
tar.add(path)
1142+
with unittest.mock.patch('os.listdir') as mock_listdir:
1143+
mock_listdir.return_value = ["2", "1"]
1144+
tar.add(path)
11451145
paths = []
11461146
for m in tar.getmembers():
11471147
paths.append(os.path.split(m.name)[-1])

0 commit comments

Comments
 (0)