| 1 |
from importlib import machinery |
| 2 |
import unittest |
| 3 |
|
| 4 |
from test.test_importlib import util |
| 5 |
|
| 6 |
|
| 7 |
class SpecLoaderMock: |
| 8 |
|
| 9 |
def find_spec(self, fullname, path=None, target=None): |
| 10 |
return machinery.ModuleSpec(fullname, self) |
| 11 |
|
| 12 |
def create_module(self, spec): |
| 13 |
return None |
| 14 |
|
| 15 |
def exec_module(self, module): |
| 16 |
pass |
| 17 |
|
| 18 |
|
| 19 |
class SpecLoaderAttributeTests: |
| 20 |
|
| 21 |
def test___loader__(self): |
| 22 |
loader = SpecLoaderMock() |
| 23 |
with util.uncache('blah'), util.import_state(meta_path=[loader]): |
| 24 |
module = self.__import__('blah') |
| 25 |
self.assertEqual(loader, module.__loader__) |
| 26 |
|
| 27 |
|
| 28 |
(Frozen_SpecTests, |
| 29 |
Source_SpecTests |
| 30 |
) = util.test_both(SpecLoaderAttributeTests, __import__=util.__import__) |
| 31 |
|
| 32 |
|
| 33 |
if __name__ == '__main__': |
| 34 |
unittest.main() |