コード例 #1
0
ファイル: test_importer.py プロジェクト: sunliwen/behave
    def test_get__should_succeed_for_known_object(self):
        lazy = LazyObject("behave.importer", "LazyObject")
        value = lazy.get()
        assert value is LazyObject

        lazy2 = LazyObject("behave.importer:LazyObject")
        value2 = lazy2.get()
        assert value2 is LazyObject

        lazy3 = LazyObject("behave.formatter.steps", "StepsFormatter")
        value3 = lazy3.get()
        assert issubclass(value3, Formatter)
コード例 #2
0
    def test_get__should_succeed_for_known_object(self):
        lazy = LazyObject("behave.importer", "LazyObject")
        value = lazy.get()
        assert value is LazyObject

        lazy2 = LazyObject("behave.importer:LazyObject")
        value2 = lazy2.get()
        assert value2 is LazyObject

        lazy3 = LazyObject("behave.formatter.steps", "StepsFormatter")
        value3 = lazy3.get()
        assert issubclass(value3, Formatter)
コード例 #3
0
 def test_get__should_fail_for_unknown_object_in_module(self):
     lazy = LazyObject("test._importer_candidate", "xxx")
     with pytest.raises(ImportError):
         lazy.get()
コード例 #4
0
 def test_get__should_fail_for_unknown_module(self):
     lazy = LazyObject("__unknown_module__", "xxx")
     with pytest.raises(ImportError):
         lazy.get()