Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refs #17876: enhanced new test to actually test underlying function, …

…not just ensure trying to use it does not raise an exception. Thanks Przemek Lewandowski.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17695 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d174216587197dcc6c4c9abcacb8e428a1f078bf 1 parent 37d0488
@kmtracey kmtracey authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 tests/modeltests/defer/tests.py
View
15 tests/modeltests/defer/tests.py
@@ -146,6 +146,15 @@ def test_defer(self):
obj.save()
def test_defer_proxy(self):
- # using select related and only should not result in Exception
- for obj in ChildProxy.objects.all().select_related().only('id'):
- continue
+ """
+ Ensure select_related together with only on a proxy model behaves
+ as expected. See #17876.
+ """
+ related = Secondary.objects.create(first='x1', second='x2')
+ ChildProxy.objects.create(name='p1', value='xx', related=related)
+ children = ChildProxy.objects.all().select_related().only('id', 'name')
+ self.assertEqual(len(children), 1)
+ child = children[0]
+ self.assert_delayed(child, 1)
+ self.assertEqual(child.name, 'p1')
+ self.assertEqual(child.value, 'xx')
Please sign in to comment.
Something went wrong with that request. Please try again.