def test_bad_module(self):
     with pytest.raises(ImportError):
         import_object('an.invalid.module')
 def test_bad_object_name(self):
     with pytest.raises(AttributeError):
         import_object(__name__ + '.InvalidName')
    def test_function(self):
        imported = import_object(__name__ + '.dummy_function')

        assert imported is dummy_function
    def test_class_method(self):
        imported = import_object(__name__ + '.DummyClass.a_method')

        assert imported is DummyClass.a_method
    def test_class(self):
        imported = import_object(__name__ + '.DummyClass')

        assert imported is DummyClass
예제 #6
0
def test_import_object():
    dummy_class = import_object(__name__ + '.DummyClass')

    assert dummy_class is DummyClass