Ticket #17673: broken_inheritance.diff

File broken_inheritance.diff, 859 bytes (added by Anssi Kääriäinen, 13 years ago)

test demonstrating the problem with field shadowing

  • tests/modeltests/model_inheritance/tests.py

    diff --git a/tests/modeltests/model_inheritance/tests.py b/tests/modeltests/model_inheritance/tests.py
    index 2e1a7a5..459d274 100644
    a b from .models import (Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place,  
    1010
    1111
    1212class ModelInheritanceTests(TestCase):
     13    def test_broken_inheritance(self):
     14        w = Worker(name="Not Wilma", age=349)
     15        w.save()
     16        sw1 = StudentWorker()
     17        sw1.name = "Wilma"
     18        sw1.age = 35
     19        sw1.save()
     20        w = Worker.objects.get(pk=w.pk)
     21        self.assertEquals(w.name, "Not Wilma")
     22
    1323    def test_abstract(self):
    1424        # The Student and Worker models both have 'name' and 'age' fields on
    1525        # them and inherit the __unicode__() method, just as with normal Python
Back to Top