From f2026ca5e29273771f4dba75ca99b8dd5812e047 Mon Sep 17 00:00:00 2001 From: Adnan Umer Date: Thu, 19 Apr 2018 15:09:54 +0500 Subject: Fixed #29337 -- Added __len__() & __bool__() to RawQuerySet. --- tests/raw_query/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index 1f0d0c363f..703a6b311e 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -330,3 +330,11 @@ class RawQueryTests(TestCase): books = Book.objects.raw('SELECT * FROM raw_query_book') list(books.iterator()) list(books.iterator()) + + def test_bool(self): + self.assertIs(bool(Book.objects.raw('SELECT * FROM raw_query_book')), True) + self.assertIs(bool(Book.objects.raw('SELECT * FROM raw_query_book WHERE id = 0')), False) + + def test_len(self): + self.assertEqual(len(Book.objects.raw('SELECT * FROM raw_query_book')), 4) + self.assertEqual(len(Book.objects.raw('SELECT * FROM raw_query_book WHERE id = 0')), 0) -- cgit v1.3