mirror of
https://github.com/django/django.git
synced 2025-09-25 03:32:37 +00:00
Improved Model.__init__() properties loop.
This improves readability, accumulates unrecognized arguments raise an exception with all of them, and avoids refetching the values.
This commit is contained in:
parent
0a4a5e5bac
commit
08d8bccbf1
3 changed files with 33 additions and 14 deletions
|
@ -78,13 +78,23 @@ 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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue