Пример #1
0
class TestModuleFinder(unittest.TestCase):
    def setUp(self):
        self.finder = ModuleFinder(mock_decorator)

    def tearDown(self):
        self.finder.uninstall()

    def test_module_found(self):
        self.finder.install()
        import typesafety.tests.mockmodule
        self.assertTrue(self.finder.installed)
        self.assertTrue(
            isdecorated(typesafety.tests.mockmodule.function)
        )
        self.assertTrue(
            isdecorated(typesafety.tests.mockmodule.ModuleClass.method)
        )

    def test_module_found_but_filtered_out(self):
        self.finder.set_filter(lambda name: False)
        self.finder.install()
        import typesafety.tests.mockmodule
        self.assertFalse(
            isdecorated(typesafety.tests.mockmodule.function)
        )
        self.assertFalse(
            isdecorated(typesafety.tests.mockmodule.ModuleClass.method)
        )
Пример #2
0
 def setUp(self):
     self.finder = ModuleFinder(mock_decorator)