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

Method test_copytree_simple

Lib/test/test_shutil.py:752–769  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

750class TestCopyTree(BaseTest, unittest.TestCase):
751
752 def test_copytree_simple(self):
753 src_dir = self.mkdtemp()
754 dst_dir = os.path.join(self.mkdtemp(), 'destination')
755 self.addCleanup(shutil.rmtree, src_dir)
756 self.addCleanup(shutil.rmtree, os.path.dirname(dst_dir))
757 create_file((src_dir, 'test.txt'), '123')
758 os.mkdir(os.path.join(src_dir, 'test_dir'))
759 create_file((src_dir, 'test_dir', 'test.txt'), '456')
760
761 shutil.copytree(src_dir, dst_dir)
762 self.assertTrue(os.path.isfile(os.path.join(dst_dir, 'test.txt')))
763 self.assertTrue(os.path.isdir(os.path.join(dst_dir, 'test_dir')))
764 self.assertTrue(os.path.isfile(os.path.join(dst_dir, 'test_dir',
765 'test.txt')))
766 actual = read_file((dst_dir, 'test.txt'))
767 self.assertEqual(actual, '123')
768 actual = read_file((dst_dir, 'test_dir', 'test.txt'))
769 self.assertEqual(actual, '456')
770
771 def test_copytree_dirs_exist_ok(self):
772 src_dir = self.mkdtemp()

Callers

nothing calls this directly

Calls 11

read_fileFunction · 0.85
mkdtempMethod · 0.80
addCleanupMethod · 0.80
assertTrueMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
dirnameMethod · 0.45
mkdirMethod · 0.45
isfileMethod · 0.45
isdirMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected