From 2e0cd26ffb29189add1e0435913fd1490f52b20d Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 30 Mar 2016 12:01:33 -0400 Subject: [PATCH] Made a few proxy_models tests use assertRaisesMessage(). --- tests/proxy_models/tests.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index 3f1d0d7a80..9c2eccb3e5 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -105,37 +105,26 @@ class ProxyModelTests(TestCase): with self.assertRaises(Person.MultipleObjectsReturned): StatusPerson.objects.get(id__lt=max_id + 1) - def test_abc(self): - """ - All base classes must be non-abstract - """ - def build_abc(): + def test_abstract_base_with_model_fields(self): + msg = "Abstract base class containing model fields not permitted for proxy model 'NoAbstract'." + with self.assertRaisesMessage(TypeError, msg): class NoAbstract(Abstract): class Meta: proxy = True - with self.assertRaises(TypeError): - build_abc() - @isolate_apps('proxy_models') - def test_no_cbc(self): - """ - The proxy must actually have one concrete base class - """ - def build_no_cbc(): - class TooManyBases(Person, Abstract): + def test_too_many_concrete_classes(self): + msg = "Proxy model 'TooManyBases' has more than one non-abstract model base class." + with self.assertRaisesMessage(TypeError, msg): + class TooManyBases(User, Person): class Meta: proxy = True - with self.assertRaises(TypeError): - build_no_cbc() - @isolate_apps('proxy_models') def test_no_base_classes(self): - def build_no_base_classes(): + msg = "Proxy model 'NoBaseClasses' has no non-abstract model base class." + with self.assertRaisesMessage(TypeError, msg): class NoBaseClasses(models.Model): class Meta: proxy = True - with self.assertRaises(TypeError): - build_no_base_classes() @isolate_apps('proxy_models') def test_new_fields(self):