| 1 |
import abc |
| 2 |
|
| 3 |
|
| 4 |
class FinderTests(metaclass=abc.ABCMeta): |
| 5 |
|
| 6 |
"""Basic tests for a finder to pass.""" |
| 7 |
|
| 8 |
@abc.abstractmethod |
| 9 |
def test_module(self): |
| 10 |
# Test importing a top-level module. |
| 11 |
pass |
| 12 |
|
| 13 |
@abc.abstractmethod |
| 14 |
def test_package(self): |
| 15 |
# Test importing a package. |
| 16 |
pass |
| 17 |
|
| 18 |
@abc.abstractmethod |
| 19 |
def test_module_in_package(self): |
| 20 |
# Test importing a module contained within a package. |
| 21 |
# A value for 'path' should be used if for a meta_path finder. |
| 22 |
pass |
| 23 |
|
| 24 |
@abc.abstractmethod |
| 25 |
def test_package_in_package(self): |
| 26 |
# Test importing a subpackage. |
| 27 |
# A value for 'path' should be used if for a meta_path finder. |
| 28 |
pass |
| 29 |
|
| 30 |
@abc.abstractmethod |
| 31 |
def test_package_over_module(self): |
| 32 |
# Test that packages are chosen over modules. |
| 33 |
pass |
| 34 |
|
| 35 |
@abc.abstractmethod |
| 36 |
def test_failure(self): |
| 37 |
# Test trying to find a module that cannot be handled. |
| 38 |
pass |
| 39 |
|
| 40 |
|
| 41 |
class LoaderTests(metaclass=abc.ABCMeta): |
| 42 |
|
| 43 |
@abc.abstractmethod |
| 44 |
def test_module(self): |
| 45 |
"""A module should load without issue. |
| 46 |
|
| 47 |
After the loader returns the module should be in sys.modules. |
| 48 |
|
| 49 |
Attributes to verify: |
| 50 |
|
| 51 |
* __file__ |
| 52 |
* __loader__ |
| 53 |
* __name__ |
| 54 |
* No __path__ |
| 55 |
|
| 56 |
""" |
| 57 |
pass |
| 58 |
|
| 59 |
@abc.abstractmethod |
| 60 |
def test_package(self): |
| 61 |
"""Loading a package should work. |
| 62 |
|
| 63 |
After the loader returns the module should be in sys.modules. |
| 64 |
|
| 65 |
Attributes to verify: |
| 66 |
|
| 67 |
* __name__ |
| 68 |
* __file__ |
| 69 |
* __package__ |
| 70 |
* __path__ |
| 71 |
* __loader__ |
| 72 |
|
| 73 |
""" |
| 74 |
pass |
| 75 |
|
| 76 |
@abc.abstractmethod |
| 77 |
def test_lacking_parent(self): |
| 78 |
"""A loader should not be dependent on it's parent package being |
| 79 |
imported.""" |
| 80 |
pass |
| 81 |
|
| 82 |
@abc.abstractmethod |
| 83 |
def test_state_after_failure(self): |
| 84 |
"""If a module is already in sys.modules and a reload fails |
| 85 |
(e.g. a SyntaxError), the module should be in the state it was before |
| 86 |
the reload began.""" |
| 87 |
pass |
| 88 |
|
| 89 |
@abc.abstractmethod |
| 90 |
def test_unloadable(self): |
| 91 |
"""Test ImportError is raised when the loader is asked to load a module |
| 92 |
it can't.""" |
| 93 |
pass |