Пример #1
0
 def test_package_has_no_reader_fallback(self):
     # Test odd ball packages which:
     # 1. Do not have a ResourceReader as a loader
     # 2. Are not on the file system
     # 3. Are not in a zip file
     module = util.create_package(file=data01,
                                  path=data01.__file__,
                                  contents=['A', 'B', 'C'])
     # Give the module a dummy loader.
     module.__loader__ = object()
     # Give the module a dummy origin.
     module.__file__ = '/path/which/shall/not/be/named'
     module.__spec__.loader = module.__loader__
     module.__spec__.origin = module.__file__
     self.assertFalse(resources.is_resource(module, 'A'))
Пример #2
0
 def test_resource_missing_is_not_resource(self):
     package = util.create_package(file=data01,
                                   path=data01.__file__,
                                   contents=['A', 'B', 'C', 'D/E', 'D/F'])
     self.assertFalse(resources.is_resource(package, 'Z'))
Пример #3
0
 def test_is_submodule_resource(self):
     self.assertTrue(
         resources.is_resource(import_module('namespacedata01'),
                               'binary.file'))
Пример #4
0
 def test_read_submodule_resource_by_name(self):
     self.assertTrue(resources.is_resource('namespacedata01',
                                           'binary.file'))
Пример #5
0
 def test_is_resource_missing(self):
     self.assertFalse(resources.is_resource(self.data, 'not-a-file'))
Пример #6
0
 def test_is_resource_subresource_directory(self):
     # Directories are not resources.
     self.assertFalse(resources.is_resource(self.data, 'subdirectory'))
Пример #7
0
 def test_is_resource_failure_does_not_keep_open(self):
     c = resources.is_resource('ziptestdata', 'not-present')
     self.zip_path.unlink()
     del c
Пример #8
0
 def test_is_resource_does_not_keep_open(self):
     c = resources.is_resource('ziptestdata', 'binary.file')
     self.zip_path.unlink()
     del c
Пример #9
0
 def test_is_resource_good_path(self):
     self.assertTrue(resources.is_resource(self.data, 'binary.file'))
Пример #10
0
 def test_read_submodule_resource_by_name(self):
     self.assertTrue(
         resources.is_resource('ziptestdata.subdirectory', 'binary.file'))
Пример #11
0
 def test_is_submodule_resource(self):
     submodule = import_module('ziptestdata.subdirectory')
     self.assertTrue(resources.is_resource(submodule, 'binary.file'))