|
1 | 1 | import sys |
2 | 2 | import unittest |
3 | | - |
4 | 3 | import importlib_resources as resources |
| 4 | + |
5 | 5 | from . import data01 |
6 | | -from . import zipdata02 |
| 6 | +from . import zipdata01, zipdata02 |
7 | 7 | from . import util |
| 8 | +from importlib import import_module |
8 | 9 |
|
9 | 10 |
|
10 | 11 | class ResourceTests: |
@@ -94,7 +95,31 @@ def test_package_has_no_reader_fallback(self): |
94 | 95 | self.assertFalse(resources.is_resource(module, 'A')) |
95 | 96 |
|
96 | 97 |
|
97 | | -class ResourceFromZipsTest(util.ZipSetupBase, unittest.TestCase): |
| 98 | +class ResourceFromZipsTest01(util.ZipSetupBase, unittest.TestCase): |
| 99 | + ZIP_MODULE = zipdata01 # type: ignore |
| 100 | + |
| 101 | + def test_is_submodule_resource(self): |
| 102 | + submodule = import_module('ziptestdata.subdirectory') |
| 103 | + self.assertTrue( |
| 104 | + resources.is_resource(submodule, 'binary.file')) |
| 105 | + |
| 106 | + def test_read_submodule_resource_by_name(self): |
| 107 | + self.assertTrue( |
| 108 | + resources.is_resource('ziptestdata.subdirectory', 'binary.file')) |
| 109 | + |
| 110 | + def test_submodule_contents(self): |
| 111 | + submodule = import_module('ziptestdata.subdirectory') |
| 112 | + self.assertEqual( |
| 113 | + set(resources.contents(submodule)), |
| 114 | + {'__init__.py', 'binary.file'}) |
| 115 | + |
| 116 | + def test_submodule_contents_by_name(self): |
| 117 | + self.assertEqual( |
| 118 | + set(resources.contents('ziptestdata.subdirectory')), |
| 119 | + {'__init__.py', 'binary.file'}) |
| 120 | + |
| 121 | + |
| 122 | +class ResourceFromZipsTest02(util.ZipSetupBase, unittest.TestCase): |
98 | 123 | ZIP_MODULE = zipdata02 # type: ignore |
99 | 124 |
|
100 | 125 | def test_unrelated_contents(self): |
|
0 commit comments