1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #16137 - Removed kwargs requirement for QuerySet.get_or_create

Thanks wilfred@, poirier, and charettes for work
on the patch.
This commit is contained in:
Tim Graham
2013-05-24 16:36:09 -04:00
committed by Tim Graham
parent a64de33b79
commit 90af278203
5 changed files with 23 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ from django.db import IntegrityError, DatabaseError
from django.utils.encoding import DjangoUnicodeDecodeError
from django.test import TestCase, TransactionTestCase
from .models import Person, ManualPrimaryKeyTest, Profile, Tag, Thing
from .models import DefaultPerson, Person, ManualPrimaryKeyTest, Profile, Tag, Thing
class GetOrCreateTests(TestCase):
@@ -83,6 +83,14 @@ class GetOrCreateTests(TestCase):
else:
self.skipTest("This backend accepts broken utf-8.")
def test_get_or_create_empty(self):
# Regression test for #16137: get_or_create does not require kwargs.
try:
DefaultPerson.objects.get_or_create()
except AssertionError:
self.fail("If all the attributes on a model have defaults, we "
"shouldn't need to pass any arguments.")
class GetOrCreateTransactionTests(TransactionTestCase):