Skip to content

Commit e4d9631

Browse files
authored
Merge pull request #220 from FFY00/test-contents
tests: add test for contents()
2 parents 064fa89 + d901af0 commit e4d9631

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import unittest
2+
import importlib_resources as resources
3+
4+
from . import data01
5+
from . import util
6+
7+
8+
class ContentsTests:
9+
expected = {
10+
'__init__.py',
11+
'binary.file',
12+
'subdirectory',
13+
'utf-16.file',
14+
'utf-8.file',
15+
}
16+
17+
def test_contents(self):
18+
assert self.expected <= set(resources.contents(self.data))
19+
20+
21+
class ContentsDiskTests(ContentsTests, unittest.TestCase):
22+
def setUp(self):
23+
self.data = data01
24+
25+
26+
class ContentsZipTests(ContentsTests, util.ZipSetup, unittest.TestCase):
27+
pass
28+
29+
30+
class ContentsNamespaceTests(ContentsTests, unittest.TestCase):
31+
expected = {
32+
# no __init__ because of namespace design
33+
# no subdirectory as incidental difference in fixture
34+
'binary.file',
35+
'utf-16.file',
36+
'utf-8.file',
37+
}
38+
39+
def setUp(self):
40+
from . import namespacedata01
41+
42+
self.data = namespacedata01

0 commit comments

Comments
 (0)