Ticket #17876: better_test.diff

File better_test.diff, 958 bytes (added by Przemek Lewandowski <prze.lewandowski@…>, 13 years ago)

Patch with improved test.

  • tests/modeltests/defer/tests.py

    diff --git a/tests/modeltests/defer/tests.py b/tests/modeltests/defer/tests.py
    index 88aac0c..5f3b777 100644
    a b class DeferTests(TestCase):  
    147147
    148148    def test_defer_proxy(self):
    149149        # using select related and only should not result in Exception
    150         for obj in ChildProxy.objects.all().select_related().only('id'):
    151             continue
     150        related = Secondary.objects.create(first='x1', second='x2')
     151        ChildProxy.objects.create(name='p1', value='xx', related=related)
     152       
     153        children = ChildProxy.objects.all().select_related().only('id')
     154       
     155        # This is different than direct evaluation to list
     156        for obj in children:
     157            self.assert_delayed(obj, 2)
     158            self.assertEqual(obj.name, 'p1')
     159            self.assertEqual(obj.value, 'xx')
     160           
     161        self.assertEqual(len(children), 1)
     162
Back to Top