Kaydet (Commit) bcce6bb7 authored tarafından Josh Smeaton's avatar Josh Smeaton

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.
üst 4e48cfc1
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment