From 4d48ddd8f93800a80330ec1dee7b7d4afe6ea95a Mon Sep 17 00:00:00 2001 From: Josh Schneier Date: Sun, 15 Jul 2018 17:47:17 -0400 Subject: Fixed #28917 -- Prevented Paginator's unordered warning on EmptyQuerySet. Thanks carltongibson for the idea and weijunji for the initial patch. --- tests/pagination/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/pagination') diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py index f13afc308f..987e713405 100644 --- a/tests/pagination/tests.py +++ b/tests/pagination/tests.py @@ -1,4 +1,5 @@ import unittest +import warnings from datetime import datetime from django.core.paginator import ( @@ -368,6 +369,11 @@ class ModelPaginationTests(TestCase): # is appropriate). self.assertEqual(cm.filename, __file__) + def test_paginating_empty_queryset_does_not_warn(self): + with warnings.catch_warnings(record=True) as recorded: + Paginator(Article.objects.none(), 5) + self.assertEqual(len(recorded), 0) + def test_paginating_unordered_object_list_raises_warning(self): """ Unordered object list warning with an object that has an orderd -- cgit v1.2.1