diff options
| author | Tim Graham <timograham@gmail.com> | 2015-10-05 19:07:34 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-10-06 12:38:34 -0400 |
| commit | e0837f2cb12de5e95e621d19b186b0da43bcdee2 (patch) | |
| tree | ea6ae0b150304ed18d93fb8c3ee3b7defbda0e26 /tests | |
| parent | 3543fec3b739864c52de0a116dde3b0e5e885799 (diff) | |
Fixed #25508 -- Modified QuerySet.__repr__() to disambiguate it from a list.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fixtures_regress/tests.py | 11 | ||||
| -rw-r--r-- | tests/null_queries/tests.py | 2 | ||||
| -rw-r--r-- | tests/string_lookup/tests.py | 6 |
3 files changed, 11 insertions, 8 deletions
diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py index 02a841f5ef..5edd1c722f 100644 --- a/tests/fixtures_regress/tests.py +++ b/tests/fixtures_regress/tests.py @@ -800,11 +800,12 @@ class NaturalKeyFixtureTests(TestCase): verbosity=0, ) books = Book.objects.all() - self.assertEqual( - books.__repr__(), - "[<Book: Cryptonomicon by Neal Stephenson (available at Amazon, Borders)>, " - "<Book: Ender's Game by Orson Scott Card (available at Collins Bookstore)>, " - "<Book: Permutation City by Greg Egan (available at Angus and Robertson)>]" + self.assertQuerysetEqual( + books, [ + "<Book: Cryptonomicon by Neal Stephenson (available at Amazon, Borders)>", + "<Book: Ender's Game by Orson Scott Card (available at Collins Bookstore)>", + "<Book: Permutation City by Greg Egan (available at Angus and Robertson)>", + ] ) diff --git a/tests/null_queries/tests.py b/tests/null_queries/tests.py index 8c8ca3f28d..3ba307d397 100644 --- a/tests/null_queries/tests.py +++ b/tests/null_queries/tests.py @@ -47,7 +47,7 @@ class NullQueriesTests(TestCase): # Related managers use __exact=None implicitly if the object hasn't been saved. p2 = Poll(question="How?") - self.assertEqual(repr(p2.choice_set.all()), '[]') + self.assertEqual(repr(p2.choice_set.all()), '<QuerySet []>') def test_reverse_relations(self): """ diff --git a/tests/string_lookup/tests.py b/tests/string_lookup/tests.py index 13a4544604..5f9d519bf5 100644 --- a/tests/string_lookup/tests.py +++ b/tests/string_lookup/tests.py @@ -78,7 +78,9 @@ class StringLookupTests(TestCase): """ a = Article(name='IP test', text='The body', submitted_from='192.0.2.100') a.save() - self.assertEqual(repr(Article.objects.filter(submitted_from__contains='192.0.2')), - repr([a])) + self.assertQuerysetEqual( + Article.objects.filter(submitted_from__contains='192.0.2'), + [a], lambda x: x + ) # Test that the searches do not match the subnet mask (/32 in this case) self.assertEqual(Article.objects.filter(submitted_from__contains='32').count(), 0) |
