mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
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 4ad703b7ca
)
Co-authored-by: Bernhard M. Wiedemann <githubbmw@lsmod.de>
This commit is contained in:
parent
2bb0bfafb0
commit
2c6f668276
1 changed files with 4 additions and 4 deletions
|
@ -1131,17 +1131,17 @@ class WriteTest(WriteTestBase, unittest.TestCase):
|
||||||
|
|
||||||
# mock the following:
|
# mock the following:
|
||||||
# os.listdir: so we know that files are in the wrong order
|
# os.listdir: so we know that files are in the wrong order
|
||||||
@unittest.mock.patch('os.listdir')
|
def test_ordered_recursion(self):
|
||||||
def test_ordered_recursion(self, mock_listdir):
|
|
||||||
path = os.path.join(TEMPDIR, "directory")
|
path = os.path.join(TEMPDIR, "directory")
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
open(os.path.join(path, "1"), "a").close()
|
open(os.path.join(path, "1"), "a").close()
|
||||||
open(os.path.join(path, "2"), "a").close()
|
open(os.path.join(path, "2"), "a").close()
|
||||||
mock_listdir.return_value = ["2", "1"]
|
|
||||||
try:
|
try:
|
||||||
tar = tarfile.open(tmpname, self.mode)
|
tar = tarfile.open(tmpname, self.mode)
|
||||||
try:
|
try:
|
||||||
tar.add(path)
|
with unittest.mock.patch('os.listdir') as mock_listdir:
|
||||||
|
mock_listdir.return_value = ["2", "1"]
|
||||||
|
tar.add(path)
|
||||||
paths = []
|
paths = []
|
||||||
for m in tar.getmembers():
|
for m in tar.getmembers():
|
||||||
paths.append(os.path.split(m.name)[-1])
|
paths.append(os.path.split(m.name)[-1])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue