Example #1
0
    def test_get_module_from_path(self):
        # test a path that doesn't have a module
        assert em.get_module_from_path(Path('foo')) is None

        path = Path(__file__)

        # test this file is a module
        mod = em.get_module_from_path(path)
        assert mod
        assert len([name for name in dir(mod) if not em.is_dunder(name)]) > 0

        # test we get a module from a directory
        assert em.get_module_from_path(path.parent)
Example #2
0
 def test_is_dunder(self):
     assert em.is_dunder('__foo__')
     assert not em.is_dunder('_foo_')
     assert not em.is_dunder('__foo')
     assert not em.is_dunder('foo__')
     assert not em.is_dunder('foo')