From 5f1670ffa2cdbd790436b9af1bd260d3a3058005 Mon Sep 17 00:00:00 2001 From: Stefan Wojcik Date: Sun, 7 May 2017 23:46:08 -0400 Subject: [PATCH] fix a unit test that fails from time to time --- tests/queryset/queryset.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/queryset/queryset.py b/tests/queryset/queryset.py index 4a26a4b6..d97b307d 100644 --- a/tests/queryset/queryset.py +++ b/tests/queryset/queryset.py @@ -4646,7 +4646,6 @@ class QuerySetTest(unittest.TestCase): def test_no_cache(self): """Ensure you can add meta data to file""" - class Noddy(Document): fields = DictField() @@ -4664,15 +4663,19 @@ class QuerySetTest(unittest.TestCase): self.assertEqual(len(list(docs)), 100) + # Can't directly get a length of a no-cache queryset. with self.assertRaises(TypeError): len(docs) + # Another iteration over the queryset should result in another db op. with query_counter() as q: - self.assertEqual(q, 0) list(docs) self.assertEqual(q, 1) + + # ... and another one to double-check. + with query_counter() as q: list(docs) - self.assertEqual(q, 2) + self.assertEqual(q, 1) def test_nested_queryset_iterator(self): # Try iterating the same queryset twice, nested.