summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2017-01-14 13:12:24 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2017-01-14 15:41:49 +1100
commitbcce6bb7c7c494905b516cbed576f2fd0282e6f1 (patch)
treecdd92d4e2fdc86d1d2827136d0e5d5102052934b
parent4e48cfc108c6cf69052cc728e72dc2cb25a880a5 (diff)
Changed a test to be consistent when run in parallel.
This particular test was sometimes failing when running the test suite in parallel. The `id` was different depending on the order the tests were run. The test was incorrectly comparing model primary keys rather than ensuring they didn't change.
-rw-r--r--tests/queries/tests.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 8f0af65c8d..b0999be3f8 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -1645,6 +1645,8 @@ class Queries5Tests(TestCase):
def test_ticket9848(self):
# Make sure that updates which only filter on sub-tables don't
# inadvertently update the wrong records (bug #9848).
+ author_start = Author.objects.get(name='a1')
+ ranking_start = Ranking.objects.get(author__name='a1')
# Make sure that the IDs from different tables don't happen to match.
self.assertQuerysetEqual(
@@ -1652,12 +1654,14 @@ class Queries5Tests(TestCase):
['<Ranking: 3: a1>']
)
self.assertEqual(
- Ranking.objects.filter(author__name='a1').update(rank='4'),
+ Ranking.objects.filter(author__name='a1').update(rank=4636),
1
)
- r = Ranking.objects.filter(author__name='a1')[0]
- self.assertNotEqual(r.id, r.author.id)
- self.assertEqual(r.rank, 4)
+
+ r = Ranking.objects.get(author__name='a1')
+ self.assertEqual(r.id, ranking_start.id)
+ self.assertEqual(r.author.id, author_start.id)
+ self.assertEqual(r.rank, 4636)
r.rank = 3
r.save()
self.assertQuerysetEqual(