MCPcopy Create free account
hub / github.com/modelscope/modelscope / test_file

Method test_file

tests/fileio/test_file.py:60–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 storage.read(url + 'df')
59
60 def test_file(self):
61 url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/texts/data.txt'
62 content = 'this is test data'
63 self.assertEqual(content.encode('utf8'), File.read(url))
64
65 with File.as_local_path(url) as local_file:
66 with open(local_file, 'r') as infile:
67 self.assertEqual(content, infile.read())
68
69 with self.assertRaises(NotImplementedError):
70 File.write('dfad', url)
71
72 with self.assertRaises(HTTPError):
73 File.read(url + 'df')
74
75 temp_name = tempfile.gettempdir() + '/' + next(
76 tempfile._get_candidate_names())
77 binary_content = b'12345'
78 File.write(binary_content, temp_name)
79 self.assertEqual(binary_content, File.read(temp_name))
80 os.remove(temp_name)
81
82
83if __name__ == '__main__':

Callers

nothing calls this directly

Calls 5

encodeMethod · 0.45
readMethod · 0.45
as_local_pathMethod · 0.45
writeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected