(self)
| 1500 | # mock the following: |
| 1501 | # os.listdir: so we know that files are in the wrong order |
| 1502 | def test_ordered_recursion(self): |
| 1503 | path = os.path.join(TEMPDIR, "directory") |
| 1504 | os.mkdir(path) |
| 1505 | open(os.path.join(path, "1"), "a").close() |
| 1506 | open(os.path.join(path, "2"), "a").close() |
| 1507 | try: |
| 1508 | tar = tarfile.open(tmpname, self.mode) |
| 1509 | try: |
| 1510 | with unittest.mock.patch('os.listdir') as mock_listdir: |
| 1511 | mock_listdir.return_value = ["2", "1"] |
| 1512 | tar.add(path) |
| 1513 | paths = [] |
| 1514 | for m in tar.getmembers(): |
| 1515 | paths.append(os.path.split(m.name)[-1]) |
| 1516 | self.assertEqual(paths, ["directory", "1", "2"]); |
| 1517 | finally: |
| 1518 | tar.close() |
| 1519 | finally: |
| 1520 | os_helper.unlink(os.path.join(path, "1")) |
| 1521 | os_helper.unlink(os.path.join(path, "2")) |
| 1522 | os_helper.rmdir(path) |
| 1523 | |
| 1524 | def test_gettarinfo_pathlike_name(self): |
| 1525 | with tarfile.open(tmpname, self.mode) as tar: |
nothing calls this directly
no test coverage detected