Ticket #23370: 23370-test.diff

File 23370-test.diff, 1.0 KB (added by Tim Graham, 8 years ago)
  • tests/model_inheritance/tests.py

    diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
    index 0af96b8..125e2cd 100644
    a b class ModelInheritanceTests(TestCase): 
    255255            1, lambda: ItalianRestaurant.objects.select_related("chef")[0].chef
    256256        )
    257257
     258    def test_select_related_defer(self):
     259        r = Restaurant.objects.create(
     260            name="Demon Dogs",
     261            address="944 W. Fullerton",
     262            serves_hot_dogs=True,
     263            serves_pizza=False,
     264            rating=2
     265        )
     266        ir = ItalianRestaurant.objects.create(
     267            name="Ristorante Miron",
     268            address="1234 W. Ash",
     269            serves_hot_dogs=False,
     270            serves_pizza=False,
     271            serves_gnocchi=True,
     272            rating=4,
     273        )
     274        list(Restaurant.objects.select_related("italianrestaurant").defer("italianrestaurant__serves_gnocchi"))
     275
    258276    def test_mixin_init(self):
    259277        m = MixinModel()
    260278        self.assertEqual(m.other_attr, 1)
Back to Top