summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-02-23 18:29:56 +0100
committerClaude Paroz <claude@2xlibre.net>2013-02-23 18:32:29 +0100
commitcc53d9b30bd73c12413c28101d5db9f9f4df517c (patch)
tree6cffa178f7c78444d86ad6bfb34893215ffe0e45 /tests
parenta05ab448f7a738d30ee7e8a513a65b6a67e8ea8e (diff)
Fixed #15877 -- Improved exception when ModelForm has no model class
Thanks theaspect at gmail.com for the report and volrath for the patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/model_forms/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/modeltests/model_forms/tests.py b/tests/modeltests/model_forms/tests.py
index fb400375b8..efaf2981e1 100644
--- a/tests/modeltests/model_forms/tests.py
+++ b/tests/modeltests/model_forms/tests.py
@@ -133,6 +133,9 @@ class ShortCategory(forms.ModelForm):
slug = forms.CharField(max_length=5)
url = forms.CharField(max_length=3)
+ class Meta:
+ model = Category
+
class ImprovedArticleForm(forms.ModelForm):
class Meta:
model = ImprovedArticle
@@ -277,6 +280,19 @@ class ModelFormBaseTest(TestCase):
['headline', 'slug', 'pub_date', 'writer', 'article', 'categories', 'status']
)
+ def test_invalid_meta_model(self):
+ class InvalidModelForm(forms.ModelForm):
+ class Meta:
+ pass # no model
+
+ # Can't create new form
+ with self.assertRaises(ValueError):
+ f = InvalidModelForm()
+
+ # Even if you provide a model instance
+ with self.assertRaises(ValueError):
+ f = InvalidModelForm(instance=Category)
+
def test_subcategory_form(self):
class SubCategoryForm(BaseCategoryForm):
""" Subclassing without specifying a Meta on the class will use