示例#1
0
    def test_copy_binary(self):
        with tempfile.TemporaryDirectory() as directory:
            source = ResourcePath("Packages/test_package/UTF-8-test.txt")
            destination = Path(directory) / 'UTF-8-test.txt'

            source.copy(destination)

            self.assertTrue(destination.is_file())

            with open(str(destination), 'rb') as file:
                data = file.read()

            self.assertEqual(data, source.read_bytes())
示例#2
0
    def test_copy_text(self):
        with tempfile.TemporaryDirectory() as directory:
            source = ResourcePath("Packages/test_package/helloworld.txt")
            destination = Path(directory) / 'helloworld.txt'

            source.copy(destination)

            self.assertTrue(destination.is_file())

            with open(str(destination), 'r') as file:
                text = file.read()

            self.assertEqual(text, source.read_text())