Conditions | 2 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | from contextlib import contextmanager |
||
24 | @contextmanager |
||
25 | def bear_test_module(): |
||
26 | """ |
||
27 | This function mocks the ``pkg_resources.iter_entry_points()`` |
||
28 | to use the testing bear module we have. Hence, it doesn't test |
||
29 | the collection of entry points. |
||
30 | """ |
||
31 | bears_test_module = os.path.join(os.path.dirname(__file__), |
||
32 | "test_bears", "__init__.py") |
||
33 | |||
34 | class EntryPoint: |
||
35 | |||
36 | @staticmethod |
||
37 | def load(): |
||
38 | class PseudoPlugin: |
||
39 | __file__ = bears_test_module |
||
40 | return PseudoPlugin() |
||
41 | |||
42 | with unittest.mock.patch("pkg_resources.iter_entry_points", |
||
43 | return_value=[EntryPoint()]) as mocked: |
||
44 | yield |
||
45 | |||
49 |