Changed AttributeError to AssertionError

This commit is contained in:
Danilo Bargen 2013-02-26 09:38:57 +01:00
parent ec4d79bcaf
commit e476dcb8c7
2 changed files with 3 additions and 4 deletions

View File

@ -424,9 +424,8 @@ class ModelSerializer(Serializer):
""" """
cls = self.opts.model cls = self.opts.model
if cls is None: assert cls is not None, \
raise AttributeError("Serializer class '%s' is missing 'model' Meta option" % "Serializer class '%s' is missing 'model' Meta option" % self.__class__.__name__
self.__class__.__name__)
opts = get_concrete_model(cls)._meta opts = get_concrete_model(cls)._meta
pk_field = opts.pk pk_field = opts.pk
# while pk_field.rel: # while pk_field.rel:

View File

@ -365,7 +365,7 @@ class ValidationTests(TestCase):
""" """
try: try:
serializer = BrokenModelSerializer() serializer = BrokenModelSerializer()
except AttributeError as e: except AssertionError as e:
self.assertEquals(e.args[0], "Serializer class 'BrokenModelSerializer' is missing 'model' Meta option") self.assertEquals(e.args[0], "Serializer class 'BrokenModelSerializer' is missing 'model' Meta option")
except: except:
self.fail('Wrong exception type thrown.') self.fail('Wrong exception type thrown.')