diff options
| author | Adam Johnson <me@adamj.eu> | 2021-12-13 15:44:07 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-01-13 11:09:37 +0100 |
| commit | 08d8bccbf1b0764a0de68325569ee47da256e206 (patch) | |
| tree | f5efe9496dedba0f7744ba87c5ef807b1b7d1fe8 /tests/basic | |
| parent | 0a4a5e5bacc354df3132d0fcf706839c21afb89d (diff) | |
| download | django-08d8bccbf1b0764a0de68325569ee47da256e206.tar.gz | |
Improved Model.__init__() properties loop.
This improves readability, accumulates unrecognized arguments raise an
exception with all of them, and avoids refetching the values.
Diffstat (limited to 'tests/basic')
| -rw-r--r-- | tests/basic/tests.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 8b40f9c33c..a3aab7baa7 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -78,12 +78,22 @@ class ModelInstanceCreationTests(TestCase): 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'"): + msg = "Article() got unexpected keyword arguments: 'foo'" + with self.assertRaisesMessage(TypeError, msg): + Article( + id=None, + headline='Some headline', + pub_date=datetime(2005, 7, 31), + foo='bar', + ) + msg = "Article() got unexpected keyword arguments: 'foo', 'bar'" + with self.assertRaisesMessage(TypeError, msg): Article( id=None, headline='Some headline', pub_date=datetime(2005, 7, 31), foo='bar', + bar='baz', ) def test_can_leave_off_value_for_autofield_and_it_gets_value_on_save(self): |
