mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed flake8 warnings introduced in recent commits.
This commit is contained in:
parent
0e45669fa9
commit
79f05616fb
5 changed files with 11 additions and 14 deletions
|
@ -19,40 +19,38 @@ class GetOrCreateTests(TestCase):
|
|||
)
|
||||
|
||||
def test_get_or_create_method_with_get(self):
|
||||
p, created = Person.objects.get_or_create(
|
||||
created = Person.objects.get_or_create(
|
||||
first_name="John", last_name="Lennon", defaults={
|
||||
"birthday": date(1940, 10, 9)
|
||||
}
|
||||
)
|
||||
)[1]
|
||||
self.assertFalse(created)
|
||||
self.assertEqual(Person.objects.count(), 1)
|
||||
|
||||
|
||||
def test_get_or_create_method_with_create(self):
|
||||
p, created = Person.objects.get_or_create(
|
||||
created = Person.objects.get_or_create(
|
||||
first_name='George', last_name='Harrison', defaults={
|
||||
'birthday': date(1943, 2, 25)
|
||||
}
|
||||
)
|
||||
)[1]
|
||||
self.assertTrue(created)
|
||||
self.assertEqual(Person.objects.count(), 2)
|
||||
|
||||
|
||||
def test_get_or_create_redundant_instance(self):
|
||||
"""
|
||||
If we execute the exact same statement twice, the second time,
|
||||
it won't create a Person.
|
||||
"""
|
||||
george, created = Person.objects.get_or_create(
|
||||
Person.objects.get_or_create(
|
||||
first_name='George', last_name='Harrison', defaults={
|
||||
'birthday': date(1943, 2, 25)
|
||||
}
|
||||
)
|
||||
evil_george, created = Person.objects.get_or_create(
|
||||
created = Person.objects.get_or_create(
|
||||
first_name='George', last_name='Harrison', defaults={
|
||||
'birthday': date(1943, 2, 25)
|
||||
}
|
||||
)
|
||||
)[1]
|
||||
|
||||
self.assertFalse(created)
|
||||
self.assertEqual(Person.objects.count(), 2)
|
||||
|
@ -67,6 +65,7 @@ class GetOrCreateTests(TestCase):
|
|||
Person.objects.get_or_create, first_name="Tom", last_name="Smith"
|
||||
)
|
||||
|
||||
|
||||
class GetOrCreateTestsWithManualPKs(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue