(self)
| 1483 | # mock the following: |
| 1484 | # os.listdir: so we know that files are in the wrong order |
| 1485 | def test_ordered_recursion(self): |
| 1486 | path = os.path.join(TEMPDIR, "directory") |
| 1487 | os.mkdir(path) |
| 1488 | open(os.path.join(path, "1"), "a").close() |
| 1489 | open(os.path.join(path, "2"), "a").close() |
| 1490 | try: |
| 1491 | tar = tarfile.open(tmpname, self.mode) |
| 1492 | try: |
| 1493 | with unittest.mock.patch('os.listdir') as mock_listdir: |
| 1494 | mock_listdir.return_value = ["2", "1"] |
| 1495 | tar.add(path) |
| 1496 | paths = [] |
| 1497 | for m in tar.getmembers(): |
| 1498 | paths.append(os.path.split(m.name)[-1]) |
| 1499 | self.assertEqual(paths, ["directory", "1", "2"]); |
| 1500 | finally: |
| 1501 | tar.close() |
| 1502 | finally: |
| 1503 | os_helper.unlink(os.path.join(path, "1")) |
| 1504 | os_helper.unlink(os.path.join(path, "2")) |
| 1505 | os_helper.rmdir(path) |
| 1506 | |
| 1507 | def test_gettarinfo_pathlike_name(self): |
| 1508 | with tarfile.open(tmpname, self.mode) as tar: |
nothing calls this directly
no test coverage detected