[Python-checkins] bpo-30693: Fix tarfile test cleanup on MSWindows (GH-5557) (GH-5567)
Serhiy Storchaka
webhook-mailer at python.org
Tue Feb 6 13:33:30 EST 2018
https://github.com/python/cpython/commit/2c6f6682768f401c297c584ef106d48c78697f67
commit: 2c6f6682768f401c297c584ef106d48c78697f67
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018-02-06T20:33:27+02:00
summary:
bpo-30693: Fix tarfile test cleanup on MSWindows (GH-5557) (GH-5567)
it was using our mocked listdir to check when the files were gone.
(cherry picked from commit 4ad703b7ca463d1183539277dde90ffb1c808487)
Co-authored-by: Bernhard M. Wiedemann <githubbmw at lsmod.de>
files:
M Lib/test/test_tarfile.py
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 8ef4294921b2..b868326d5c74 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1131,17 +1131,17 @@ def test_directory_size(self):
# mock the following:
# os.listdir: so we know that files are in the wrong order
- @unittest.mock.patch('os.listdir')
- def test_ordered_recursion(self, mock_listdir):
+ def test_ordered_recursion(self):
path = os.path.join(TEMPDIR, "directory")
os.mkdir(path)
open(os.path.join(path, "1"), "a").close()
open(os.path.join(path, "2"), "a").close()
- mock_listdir.return_value = ["2", "1"]
try:
tar = tarfile.open(tmpname, self.mode)
try:
- tar.add(path)
+ with unittest.mock.patch('os.listdir') as mock_listdir:
+ mock_listdir.return_value = ["2", "1"]
+ tar.add(path)
paths = []
for m in tar.getmembers():
paths.append(os.path.split(m.name)[-1])
More information about the Python-checkins
mailing list