Ticket #16731: 1117.patch.txt

File 1117.patch.txt, 2.5 KB (added by Marc Tamlyn, 5 years ago)

16731-failing-test.patch

Line 
1From 7c404bcf0590edcdee14177a7e9662a8388c48a4 Mon Sep 17 00:00:00 2001
2From: Koen Vossen <koen.vossen@gmail.com>
3Date: Sat, 18 May 2013 16:23:04 +0200
4Subject: [PATCH 1/2] Add test for ticket #16731.
5
6---
7 tests/queries/tests.py | 13 +++++++++++++
8 1 file changed, 13 insertions(+)
9
10diff --git a/tests/queries/tests.py b/tests/queries/tests.py
11index cdc2624..5951a31 100644
12--- a/tests/queries/tests.py
13+++ b/tests/queries/tests.py
14@@ -1480,6 +1480,19 @@ def test_ticket15316_one2one_exclude_true(self):
15         self.assertEqual(qs.count(), 2)
16         self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False)
17 
18+    # This test should succeed when ticket #16731 has been fixed.
19+    @unittest.expectedFailure
20+    def test_ticket16731(self):
21+        last_note = Note.objects.latest('id')
22+
23+        n0 = Note.objects.create(note='monty', misc='python')
24+        n1 = Note.objects.create(note='foo', misc='foobar')
25+
26+        qs = Note.objects.filter(id__gt=last_note.id)
27+        self.assertEqual(qs.count(), 2)
28+        self.assertEqual(qs.get(misc__startswith=F('note')).misc, 'foobar')
29+        self.assertEqual(qs.filter(note__startswith=F('misc')).count(), 0)
30+
31 
32 class Queries5Tests(TestCase):
33     def setUp(self):
34--
351.8.1.6
36
37
38From 6ececd689b35668657ef265e898edf7d78b3fd35 Mon Sep 17 00:00:00 2001
39From: Koen Vossen <koen.vossen@gmail.com>
40Date: Sat, 18 May 2013 16:35:01 +0200
41Subject: [PATCH 2/2] Don't assume Notes exist.
42
43---
44 tests/queries/tests.py | 7 +++++--
45 1 file changed, 5 insertions(+), 2 deletions(-)
46
47diff --git a/tests/queries/tests.py b/tests/queries/tests.py
48index 5951a31..931a103 100644
49--- a/tests/queries/tests.py
50+++ b/tests/queries/tests.py
51@@ -1483,12 +1483,15 @@ def test_ticket15316_one2one_exclude_true(self):
52     # This test should succeed when ticket #16731 has been fixed.
53     @unittest.expectedFailure
54     def test_ticket16731(self):
55-        last_note = Note.objects.latest('id')
56+        try:
57+            last_id = Note.objects.latest('id').id
58+        except Note.DoesNotExist:
59+            last_id = -1
60 
61         n0 = Note.objects.create(note='monty', misc='python')
62         n1 = Note.objects.create(note='foo', misc='foobar')
63 
64-        qs = Note.objects.filter(id__gt=last_note.id)
65+        qs = Note.objects.filter(id__gt=last_id)
66         self.assertEqual(qs.count(), 2)
67         self.assertEqual(qs.get(misc__startswith=F('note')).misc, 'foobar')
68         self.assertEqual(qs.filter(note__startswith=F('misc')).count(), 0)
69--
701.8.1.6
71
Back to Top