From 7c404bcf0590edcdee14177a7e9662a8388c48a4 Mon Sep 17 00:00:00 2001 From: Koen Vossen Date: Sat, 18 May 2013 16:23:04 +0200 Subject: [PATCH 1/2] Add test for ticket #16731. --- tests/queries/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index cdc2624..5951a31 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1480,6 +1480,19 @@ def test_ticket15316_one2one_exclude_true(self): self.assertEqual(qs.count(), 2) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) + # This test should succeed when ticket #16731 has been fixed. + @unittest.expectedFailure + def test_ticket16731(self): + last_note = Note.objects.latest('id') + + n0 = Note.objects.create(note='monty', misc='python') + n1 = Note.objects.create(note='foo', misc='foobar') + + qs = Note.objects.filter(id__gt=last_note.id) + self.assertEqual(qs.count(), 2) + self.assertEqual(qs.get(misc__startswith=F('note')).misc, 'foobar') + self.assertEqual(qs.filter(note__startswith=F('misc')).count(), 0) + class Queries5Tests(TestCase): def setUp(self): -- 1.8.1.6 From 6ececd689b35668657ef265e898edf7d78b3fd35 Mon Sep 17 00:00:00 2001 From: Koen Vossen Date: Sat, 18 May 2013 16:35:01 +0200 Subject: [PATCH 2/2] Don't assume Notes exist. --- tests/queries/tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 5951a31..931a103 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1483,12 +1483,15 @@ def test_ticket15316_one2one_exclude_true(self): # This test should succeed when ticket #16731 has been fixed. @unittest.expectedFailure def test_ticket16731(self): - last_note = Note.objects.latest('id') + try: + last_id = Note.objects.latest('id').id + except Note.DoesNotExist: + last_id = -1 n0 = Note.objects.create(note='monty', misc='python') n1 = Note.objects.create(note='foo', misc='foobar') - qs = Note.objects.filter(id__gt=last_note.id) + qs = Note.objects.filter(id__gt=last_id) self.assertEqual(qs.count(), 2) self.assertEqual(qs.get(misc__startswith=F('note')).misc, 'foobar') self.assertEqual(qs.filter(note__startswith=F('misc')).count(), 0) -- 1.8.1.6