1 import typing
2 import unittest
3
4 from importlib import resources
5 from importlib.abc import Traversable
6 from . import data01
7 from .resources import util
8
9
10 class ESC[4;38;5;81mFilesTests:
11 def test_read_bytes(self):
12 files = resources.files(self.data)
13 actual = files.joinpath('utf-8.file').read_bytes()
14 assert actual == b'Hello, UTF-8 world!\n'
15
16 def test_read_text(self):
17 files = resources.files(self.data)
18 actual = files.joinpath('utf-8.file').read_text(encoding='utf-8')
19 assert actual == 'Hello, UTF-8 world!\n'
20
21 @unittest.skipUnless(
22 hasattr(typing, 'runtime_checkable'),
23 "Only suitable when typing supports runtime_checkable",
24 )
25 def test_traversable(self):
26 assert isinstance(resources.files(self.data), Traversable)
27
28
29 class ESC[4;38;5;81mOpenDiskTests(ESC[4;38;5;149mFilesTests, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
30 def setUp(self):
31 self.data = data01
32
33
34 class ESC[4;38;5;81mOpenZipTests(ESC[4;38;5;149mFilesTests, ESC[4;38;5;149mutilESC[4;38;5;149m.ESC[4;38;5;149mZipSetup, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
35 pass
36
37
38 class ESC[4;38;5;81mOpenNamespaceTests(ESC[4;38;5;149mFilesTests, ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
39 def setUp(self):
40 from . import namespacedata01
41
42 self.data = namespacedata01
43
44
45 if __name__ == '__main__':
46 unittest.main()