summaryrefslogtreecommitdiff
path: root/tests/basic/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic/tests.py')
-rw-r--r--tests/basic/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py
index 43c7ccdfa6..c99fc7e723 100644
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -68,6 +68,15 @@ class ModelInstanceCreationTests(TestCase):
a.save()
self.assertEqual(a.headline, 'Fourth article')
+ def test_positional_and_keyword_args_for_the_same_field(self):
+ msg = "Article() got both positional and keyword arguments for field '%s'."
+ with self.assertRaisesMessage(TypeError, msg % 'headline'):
+ Article(None, 'Fifth article', headline='Other headline.')
+ with self.assertRaisesMessage(TypeError, msg % 'headline'):
+ Article(None, 'Sixth article', headline='')
+ with self.assertRaisesMessage(TypeError, msg % 'pub_date'):
+ Article(None, 'Seventh article', datetime(2021, 3, 1), pub_date=None)
+
def test_cannot_create_instance_with_invalid_kwargs(self):
with self.assertRaisesMessage(TypeError, "Article() got an unexpected keyword argument 'foo'"):
Article(