Ticket #18583: 18583.diff
File 18583.diff, 3.3 KB (added by , 12 years ago) |
---|
-
tests/regressiontests/queries/models.py
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 28c8585..f1dc27d 100644
a b import threading 8 8 from django.db import models 9 9 from django.utils import six 10 10 from django.utils.encoding import python_2_unicode_compatible 11 from django.contrib.auth.models import Group 11 12 12 13 13 14 class DumbCategory(models.Model): … … class Program(models.Model): 454 455 class Channel(models.Model): 455 456 programs = models.ManyToManyField(Program) 456 457 identifier = models.OneToOneField(Identifier) 458 459 # Models for #19659 460 @python_2_unicode_compatible 461 class A(models.Model): 462 pass 463 464 def __str__(self): 465 return str(self.pk) 466 467 @python_2_unicode_compatible 468 class B(models.Model): 469 a = models.ForeignKey(A) 470 471 def __str__(self): 472 return str(self.pk) 473 474 @python_2_unicode_compatible 475 class C(models.Model): 476 b = models.ForeignKey(B) 477 478 def __str__(self): 479 return str(self.pk) 480 481 @python_2_unicode_compatible 482 class D(models.Model): 483 a = models.ForeignKey(A) 484 group = models.ForeignKey(Group) 485 486 def __str__(self): 487 return str(self.pk) -
tests/regressiontests/queries/tests.py
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py index 82a8de0..9328817 100644
a b from django.test.utils import str_prefix 17 17 from django.utils import unittest 18 18 from django.utils.datastructures import SortedDict 19 19 20 from .models import (A nnotation, Article, Author, Celebrity, Child, Cover,21 Detail, DumbCategory, ExtraInfo, Fan, Item, LeafA, LoopX, LoopZ,20 from .models import (A, Annotation, Article, Author, B, C, Celebrity, Child, 21 Cover, D, Detail, DumbCategory, ExtraInfo, Fan, Group, Item, LeafA, LoopX, LoopZ, 22 22 ManagedModel, Member, NamedCategory, Note, Number, Plaything, PointerA, 23 23 Ranking, Related, Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, 24 24 Node, ObjectA, ObjectB, ObjectC, CategoryItem, SimpleCategory, … … class Queries1Tests(BaseQuerysetTest): 1113 1113 ['<Report: r1>'] 1114 1114 ) 1115 1115 1116 def test_ticket19659(self): 1117 foo = Group.objects.create(name='foo') 1118 bar = Group.objects.create(name='bar') 1119 baz = Group.objects.create(name='baz') 1120 a1 = A.objects.create() 1121 a2 = A.objects.create() 1122 a3 = A.objects.create() 1123 b1 = B.objects.create(a=a2) 1124 b2 = B.objects.create(a=a1) 1125 b3 = B.objects.create(a=a3) 1126 c1 = C.objects.create(b=b3) 1127 c2 = C.objects.create(b=b2) 1128 c3 = C.objects.create(b=b1) 1129 d1 = D.objects.create(a=a1, group=baz) 1130 d2 = D.objects.create(a=a2, group=bar) 1131 d3 = D.objects.create(a=a3, group=foo) 1132 q = C.objects.exclude(b__a__d__group__in=[foo]).order_by('pk') 1133 self.assertQuerysetEqual(q, ['<C: 2>', '<C: 3>']) 1134 q = C.objects.exclude(b__a__d__group__in=[bar]).order_by('pk') 1135 self.assertQuerysetEqual(q, ['<C: 1>', '<C: 2>']) 1136 q = C.objects.exclude(b__a__d__group__in=[baz]).order_by('pk') 1137 self.assertQuerysetEqual(q, ['<C: 1>', '<C: 3>']) 1138 1116 1139 1117 1140 class Queries2Tests(TestCase): 1118 1141 def setUp(self):