summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests/test_models.py
diff options
context:
space:
mode:
authorAnubhav Joshi <anubhav9042@gmail.com>2014-03-02 00:36:15 +0530
committerTim Graham <timograham@gmail.com>2014-03-01 15:44:42 -0500
commitbb2ca9fe6cdd490526b44b30f207c8f743bfaa84 (patch)
tree8e448c5f136ad0160d062bc65e23bc107cee656c /tests/invalid_models_tests/test_models.py
parent3273bd7b254680a5b241e2fdbc3196956b2b44e8 (diff)
Fixed #22172 -- Allowed index_together to be a single list (rather than list of lists)..
Thanks EmilStenstrom for the suggestion.
Diffstat (limited to 'tests/invalid_models_tests/test_models.py')
-rw-r--r--tests/invalid_models_tests/test_models.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 9820aea969..c4ac960773 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -45,10 +45,7 @@ class IndexTogetherTests(IsolatedModelsTestCase):
def test_list_containing_non_iterable(self):
class Model(models.Model):
class Meta:
- index_together = [
- 'non-iterable',
- 'second-non-iterable',
- ]
+ index_together = [('a', 'b'), 42]
errors = Model.check()
expected = [
@@ -139,6 +136,22 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
+ def test_non_list(self):
+ class Model(models.Model):
+ class Meta:
+ unique_together = 'not-a-list'
+
+ errors = Model.check()
+ expected = [
+ Error(
+ '"unique_together" must be a list or tuple.',
+ hint=None,
+ obj=Model,
+ id='E008',
+ ),
+ ]
+ self.assertEqual(errors, expected)
+
def test_valid_model(self):
class Model(models.Model):
one = models.IntegerField()