MCPcopy Index your code
hub / github.com/python/cpython / test_ordered_recursion

Method test_ordered_recursion

Lib/test/test_tarfile.py:1502–1522  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 12

getmembersMethod · 0.80
rmdirMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
mkdirMethod · 0.45
closeMethod · 0.45
openMethod · 0.45
addMethod · 0.45
appendMethod · 0.45
splitMethod · 0.45
assertEqualMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected