Closed jayvdb closed 2 years ago
Three tests fail as Django base now raises TypeError before InvalidModelError can be raised.
TypeError
InvalidModelError
[ 55s] =================================== FAILURES =================================== [ 55s] _ NewDealWithInheritanceTest.test_get_must_raise_an_error_if_model_is_abstract _ [ 55s] [ 55s] self = <django_dynamic_fixture.tests.test_ddf.NewDealWithInheritanceTest testMethod=test_get_must_raise_an_error_if_model_is_abstract> [ 55s] [ 55s] def test_get_must_raise_an_error_if_model_is_abstract(self): [ 55s] with pytest.raises(InvalidModelError): [ 55s] > self.ddf.get(ModelAbstract) [ 55s] [ 55s] django_dynamic_fixture/tests/test_ddf.py:329: [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] django_dynamic_fixture/ddf.py:644: in get [ 55s] instance = self.new(model_class, ddf_lesson=ddf_lesson, **kwargs) [ 55s] django_dynamic_fixture/ddf.py:536: in new [ 55s] instance = model_class() [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] [ 55s] self = <[AttributeError("'NoneType' object has no attribute 'attname'",) raised in repr()] ModelAbstract object at 0x7f7b22e875c0> [ 55s] args = (), kwargs = {} [ 55s] cls = <class 'django_dynamic_fixture.models_test.ModelAbstract'> [ 55s] opts = <Options for ModelAbstract>, _setattr = <built-in function setattr> [ 55s] _DEFERRED = <Deferred field> [ 55s] [ 55s] def __init__(self, *args, **kwargs): [ 55s] # Alias some things as locals to avoid repeat global lookups [ 55s] cls = self.__class__ [ 55s] opts = self._meta [ 55s] _setattr = setattr [ 55s] _DEFERRED = DEFERRED [ 55s] if opts.abstract: [ 55s] > raise TypeError('Abstract models cannot be instantiated.') [ 55s] E TypeError: Abstract models cannot be instantiated. [ 55s] [ 55s] /usr/lib/python3.6/site-packages/django/db/models/base.py:413: TypeError [ 55s] _ NewDealWithInheritanceTest.test_new_must_not_raise_an_error_if_model_is_abstract _ [ 55s] [ 55s] self = <django_dynamic_fixture.tests.test_ddf.NewDealWithInheritanceTest testMethod=test_new_must_not_raise_an_error_if_model_is_abstract> [ 55s] [ 55s] def test_new_must_not_raise_an_error_if_model_is_abstract(self): [ 55s] > self.ddf.new(ModelAbstract) # it does not raise an exceptions [ 55s] [ 55s] django_dynamic_fixture/tests/test_ddf.py:325: [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] django_dynamic_fixture/ddf.py:536: in new [ 55s] instance = model_class() [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] [ 55s] self = <[AttributeError("'NoneType' object has no attribute 'attname'",) raised in repr()] ModelAbstract object at 0x7f7b22f29eb8> [ 55s] args = (), kwargs = {} [ 55s] cls = <class 'django_dynamic_fixture.models_test.ModelAbstract'> [ 55s] opts = <Options for ModelAbstract>, _setattr = <built-in function setattr> [ 55s] _DEFERRED = <Deferred field> [ 55s] [ 55s] def __init__(self, *args, **kwargs): [ 55s] # Alias some things as locals to avoid repeat global lookups [ 55s] cls = self.__class__ [ 55s] opts = self._meta [ 55s] _setattr = setattr [ 55s] _DEFERRED = DEFERRED [ 55s] if opts.abstract: [ 55s] > raise TypeError('Abstract models cannot be instantiated.') [ 55s] E TypeError: Abstract models cannot be instantiated. [ 55s] [ 55s] /usr/lib/python3.6/site-packages/django/db/models/base.py:413: TypeError [ 55s] _____________ ExceptionsLayoutMessagesTest.test_InvalidModelError ______________ [ 55s] [ 55s] self = <django_dynamic_fixture.tests.test_ddf.ExceptionsLayoutMessagesTest testMethod=test_InvalidModelError> [ 55s] [ 55s] def test_InvalidModelError(self): [ 55s] try: [ 55s] > self.ddf.get(ModelAbstract) [ 55s] [ 55s] django_dynamic_fixture/tests/test_ddf.py:468: [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] django_dynamic_fixture/ddf.py:644: in get [ 55s] instance = self.new(model_class, ddf_lesson=ddf_lesson, **kwargs) [ 55s] django_dynamic_fixture/ddf.py:536: in new [ 55s] instance = model_class() [ 55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [ 55s] [ 55s] self = <[AttributeError("'NoneType' object has no attribute 'attname'",) raised in repr()] ModelAbstract object at 0x7f7b2321cf60> [ 55s] args = (), kwargs = {} [ 55s] cls = <class 'django_dynamic_fixture.models_test.ModelAbstract'> [ 55s] opts = <Options for ModelAbstract>, _setattr = <built-in function setattr> [ 55s] _DEFERRED = <Deferred field> [ 55s] [ 55s] def __init__(self, *args, **kwargs): [ 55s] # Alias some things as locals to avoid repeat global lookups [ 55s] cls = self.__class__ [ 55s] opts = self._meta [ 55s] _setattr = setattr [ 55s] _DEFERRED = DEFERRED [ 55s] if opts.abstract: [ 55s] > raise TypeError('Abstract models cannot be instantiated.') [ 55s] E TypeError: Abstract models cannot be instantiated.
Three tests fail as Django base now raises
TypeError
beforeInvalidModelError
can be raised.