예제 #1
0
    def test_copytree_exists(self):
        with tempfile.TemporaryDirectory() as directory:
            source = ResourcePath("Packages/test_package")
            destination = Path(directory) / 'tree'
            destination.mkdir()

            helloworld_file = destination / 'helloworld.txt'

            with open(str(helloworld_file), 'w') as file:
                file.write("Nothing to see here.\n")

            source.copytree(destination, exist_ok=True)

            self.assertEqual(
                {
                    path.relative_to(destination).parts
                    for path in destination.rglob('*') if path.is_file()
                }, {path.relative_to(source)
                    for path in source.rglob('*')})

            with open(str(helloworld_file)) as file:
                helloworld_contents = file.read()

            self.assertEqual(helloworld_contents,
                             (source / 'helloworld.txt').read_text())
예제 #2
0
    def test_copytree(self):
        with tempfile.TemporaryDirectory() as directory:
            source = ResourcePath("Packages/test_package")
            destination = Path(directory) / 'tree'

            source.copytree(destination)

            self.assertEqual(
                {
                    path.relative_to(destination).parts
                    for path in destination.rglob('*') if path.is_file()
                }, {path.relative_to(source)
                    for path in source.rglob('*')})