Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
importlib.test.source.test_abc_loader.PyLoaderCompatTests Class Reference
Inheritance diagram for importlib.test.source.test_abc_loader.PyLoaderCompatTests:
Inheritance graph
[legend]
Collaboration diagram for importlib.test.source.test_abc_loader.PyLoaderCompatTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def eq_attrs
def test_module
def test_package
def test_lacking_parent
def test_module_reuse
def test_state_after_failure
def test_unloadable

Static Public Attributes

 mocker = PyLoaderCompatMock

Detailed Description

Test that the suggested code to make a loader that is compatible from
Python 3.1 forward works.

Definition at line 289 of file test_abc_loader.py.


Member Function Documentation

def importlib.test.source.test_abc_loader.PyLoaderTests.eq_attrs (   self,
  ob,
  kwargs 
) [inherited]

Definition at line 210 of file test_abc_loader.py.

00210 
00211     def eq_attrs(self, ob, **kwargs):
00212         for attr, val in kwargs.items():
00213             found = getattr(ob, attr)
00214             self.assertEqual(found, val,
00215                     "{} attribute: {} != {}".format(attr, found, val))

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 240 of file test_abc_loader.py.

00240 
00241     def test_lacking_parent(self):
00242         name = 'pkg.mod'
00243         path = os.path.join('path', 'to', 'pkg', 'mod')
00244         mock = self.mocker({name: path})
00245         with util.uncache(name):
00246             module = mock.load_module(name)
00247             self.assertIn(name, sys.modules)
00248         self.eq_attrs(module, __name__=name, __file__=path, __package__='pkg',
00249                         __loader__=mock)
00250         self.assertFalse(hasattr(module, '__path__'))
00251         return mock, name

Here is the call graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 216 of file test_abc_loader.py.

00216 
00217     def test_module(self):
00218         name = '<module>'
00219         path = os.path.join('', 'path', 'to', 'module')
00220         mock = self.mocker({name: path})
00221         with util.uncache(name):
00222             module = mock.load_module(name)
00223             self.assertTrue(name in sys.modules)
00224         self.eq_attrs(module, __name__=name, __file__=path, __package__='',
00225                         __loader__=mock)
00226         self.assertTrue(not hasattr(module, '__path__'))
00227         return mock, name

Here is the call graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 252 of file test_abc_loader.py.

00252 
00253     def test_module_reuse(self):
00254         name = 'mod'
00255         path = os.path.join('path', 'to', 'mod')
00256         module = imp.new_module(name)
00257         mock = self.mocker({name: path})
00258         with util.uncache(name):
00259             sys.modules[name] = module
00260             loaded_module = mock.load_module(name)
00261             self.assertTrue(loaded_module is module)
00262             self.assertTrue(sys.modules[name] is module)
00263         return mock, name

Here is the call graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 228 of file test_abc_loader.py.

00228 
00229     def test_package(self):
00230         name = '<pkg>'
00231         path = os.path.join('path', 'to', name, '__init__')
00232         mock = self.mocker({name: path})
00233         with util.uncache(name):
00234             module = mock.load_module(name)
00235             self.assertTrue(name in sys.modules)
00236         self.eq_attrs(module, __name__=name, __file__=path,
00237                 __path__=[os.path.dirname(path)], __package__=name,
00238                 __loader__=mock)
00239         return mock, name

Here is the call graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 264 of file test_abc_loader.py.

00264 
00265     def test_state_after_failure(self):
00266         name = "mod"
00267         module = imp.new_module(name)
00268         module.blah = None
00269         mock = self.mocker({name: os.path.join('path', 'to', 'mod')})
00270         mock.source = b"1/0"
00271         with util.uncache(name):
00272             sys.modules[name] = module
00273             with self.assertRaises(ZeroDivisionError):
00274                 mock.load_module(name)
00275             self.assertTrue(sys.modules[name] is module)
00276             self.assertTrue(hasattr(module, 'blah'))
00277         return mock

Here is the call graph for this function:

Reimplemented in importlib.test.source.test_abc_loader.PyPycLoaderTests.

Definition at line 278 of file test_abc_loader.py.

00278 
00279     def test_unloadable(self):
00280         name = "mod"
00281         mock = self.mocker({name: os.path.join('path', 'to', 'mod')})
00282         mock.source = b"1/0"
00283         with util.uncache(name):
00284             with self.assertRaises(ZeroDivisionError):
00285                 mock.load_module(name)
00286             self.assertTrue(name not in sys.modules)
00287         return mock
00288 

Here is the call graph for this function:


Member Data Documentation

Reimplemented from importlib.test.source.test_abc_loader.PyLoaderTests.

Definition at line 294 of file test_abc_loader.py.


The documentation for this class was generated from the following file: