Ticket #17761: django-17761-tests.patch
File django-17761-tests.patch, 2.0 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/model_inheritance_regress/tests.py
7 7 import datetime 8 8 from operator import attrgetter 9 9 10 from django.db import IntegrityError 10 11 from django.test import TestCase 11 12 12 13 from .models import (Place, Restaurant, ItalianRestaurant, ParkingLot, 13 14 ParkingLot2, ParkingLot3, Supplier, Wholesaler, Child, SelfRefParent, 14 15 SelfRefChild, ArticleWithAuthor, M2MChild, QualityControl, DerivedM, 15 16 Person, BirthdayParty, BachelorParty, MessyBachelorParty, 16 InternalCertificationAudit, BusStation, TrainStation )17 InternalCertificationAudit, BusStation, TrainStation, Vehicle, SportsCar) 17 18 18 19 19 20 class ModelInheritanceTest(TestCase): … … 408 409 ) 409 410 self.assertIs(BusStation._meta.pk.model, BusStation) 410 411 self.assertIs(TrainStation._meta.pk.model, TrainStation) 412 413 def test_explicit_parent_pk(self): 414 # Regression test for #17761: save_base() does not properly detect 415 # when parent primary key is uninitialized CharField 416 boxster = SportsCar(pk='WP0CA2983XU622335', convertible=True) 417 try: 418 boxster.save() 419 except IntegrityError: 420 self.fail("IntegrityError should not have occurred.") -
tests/regressiontests/model_inheritance_regress/models.py
163 163 164 164 class TrainStation(Station): 165 165 zone = models.IntegerField() 166 167 # Check that child can save with explicit parent pk, #17761 168 class Vehicle(models.Model): 169 vin = models.CharField(max_length=17, primary_key=True) 170 171 class SportsCar(Vehicle): 172 convertible = models.BooleanField()