Exemple #1
0
    def test_import_from_str(self):
        with pytest.raises(AttributeError):
            import_from_str('tests.generic.UndefinedObject')

        with pytest.raises(ImportError):
            import_from_str('tests.generic.undefined_path.User')

        assert import_from_str('tests.generic.models.User') == User
Exemple #2
0
def test_import_from_str():
    with pytest.raises(AttributeError):
        import_from_str("tests.generic.UndefinedObject")

    with pytest.raises(ImportError):
        import_from_str("tests.generic.undefined_path.User")

    assert import_from_str("tests.generic.models.User") == User
    assert import_from_str(User) == User
    assert import_from_str("generic.User") == User