From e476dcb8c70f3792f01214f8d4a13c9316e11341 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 26 Feb 2013 09:38:57 +0100 Subject: [PATCH] Changed AttributeError to AssertionError --- rest_framework/serializers.py | 5 ++--- rest_framework/tests/serializer.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index d57417d92..91af2af2d 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -424,9 +424,8 @@ class ModelSerializer(Serializer): """ cls = self.opts.model - if cls is None: - raise AttributeError("Serializer class '%s' is missing 'model' Meta option" % - self.__class__.__name__) + assert cls is not None, \ + "Serializer class '%s' is missing 'model' Meta option" % self.__class__.__name__ opts = get_concrete_model(cls)._meta pk_field = opts.pk # while pk_field.rel: diff --git a/rest_framework/tests/serializer.py b/rest_framework/tests/serializer.py index d4e9cc132..36703fd9c 100644 --- a/rest_framework/tests/serializer.py +++ b/rest_framework/tests/serializer.py @@ -365,7 +365,7 @@ class ValidationTests(TestCase): """ try: serializer = BrokenModelSerializer() - except AttributeError as e: + except AssertionError as e: self.assertEquals(e.args[0], "Serializer class 'BrokenModelSerializer' is missing 'model' Meta option") except: self.fail('Wrong exception type thrown.')