Exemple #1
0
 def test_unrelated_contents(self):
     """
     Test thata zip with two unrelated subpackages return
     distinct resources. Ref python/importlib_resources#44.
     """
     self.assertEqual(set(resources.contents('ziptestdata.one')),
                      {'__init__.py', 'resource1.txt'})
     self.assertEqual(set(resources.contents('ziptestdata.two')),
                      {'__init__.py', 'resource2.txt'})
Exemple #2
0
 def test_submodule_contents_by_name(self):
     contents = set(resources.contents('namespacedata01'))
     try:
         contents.remove('__pycache__')
     except KeyError:
         pass
     self.assertEqual(contents,
                      {'binary.file', 'utf-8.file', 'utf-16.file'})
Exemple #3
0
 def test_contents(self):
     contents = set(resources.contents(self.data))
     # There may be cruft in the directory listing of the data directory.
     # It could have a __pycache__ directory,
     # an artifact of the
     # test suite importing these modules, which
     # are not germane to this test, so just filter them out.
     contents.discard('__pycache__')
     self.assertEqual(
         sorted(contents),
         [
             '__init__.py',
             'binary.file',
             'subdirectory',
             'utf-16.file',
             'utf-8.file',
         ],
     )
Exemple #4
0
 def test_resource_contents(self):
     package = util.create_package(file=data01,
                                   path=data01.__file__,
                                   contents=['A', 'B', 'C'])
     self.assertEqual(set(resources.contents(package)), {'A', 'B', 'C'})
Exemple #5
0
 def test_contents_does_not_keep_open(self):
     c = resources.contents('ziptestdata')
     self.zip_path.unlink()
     del c
Exemple #6
0
 def test_submodule_contents_by_name(self):
     self.assertEqual(
         set(resources.contents('ziptestdata.subdirectory')),
         {'__init__.py', 'binary.file'},
     )
Exemple #7
0
 def test_submodule_contents(self):
     submodule = import_module('ziptestdata.subdirectory')
     self.assertEqual(set(resources.contents(submodule)),
                      {'__init__.py', 'binary.file'})
Exemple #8
0
 def test_contents(self):
     assert self.expected <= set(resources.contents(self.data))