Code

Ticket #7669: pagination.diff

File pagination.diff, 1.7 KB (added by Alex, 6 years ago)

Fixes broken tests

Line 
1diff --git a/tests/modeltests/pagination/models.py b/tests/modeltests/pagination/models.py
2index 1f08a32..fe2e71a 100644
3--- a/tests/modeltests/pagination/models.py
4+++ b/tests/modeltests/pagination/models.py
5@@ -31,7 +31,7 @@ __test__ = {'API_TESTS':"""
6 # New/current API (Paginator/Page) #
7 ####################################
8 
9->>> from django.core.paginator import Paginator, InvalidPage
10+>>> from django.core.paginator import Paginator, EmptyPage
11 >>> paginator = Paginator(Article.objects.all(), 5)
12 >>> paginator.count
13 9
14@@ -82,15 +82,15 @@ True
15 >>> p.end_index()
16 9
17 
18-# Invalid pages raise InvalidPage.
19+# Invalid pages raise EmptyPage.
20 >>> paginator.page(0)
21 Traceback (most recent call last):
22 ...
23-InvalidPage: ...
24+EmptyPage: ...
25 >>> paginator.page(3)
26 Traceback (most recent call last):
27 ...
28-InvalidPage: ...
29+EmptyPage: ...
30 
31 # Empty paginators with allow_empty_first_page=True.
32 >>> paginator = Paginator(Article.objects.filter(id=0), 5, allow_empty_first_page=True)
33@@ -148,7 +148,7 @@ True
34 >>> from warnings import filterwarnings
35 >>> filterwarnings("ignore")
36 
37->>> from django.core.paginator import ObjectPaginator, InvalidPage
38+>>> from django.core.paginator import ObjectPaginator, EmptyPage
39 >>> paginator = ObjectPaginator(Article.objects.all(), 5)
40 >>> paginator.hits
41 9
42@@ -181,15 +181,15 @@ True
43 >>> paginator.last_on_page(1)
44 9
45 
46-# Invalid pages raise InvalidPage.
47+# Invalid pages raise EmptyPage.
48 >>> paginator.get_page(-1)
49 Traceback (most recent call last):
50 ...
51-InvalidPage: ...
52+EmptyPage: ...
53 >>> paginator.get_page(2)
54 Traceback (most recent call last):
55 ...
56-InvalidPage: ...
57+EmptyPage: ...
58 
59 # Empty paginators with allow_empty_first_page=True.
60 >>> paginator = ObjectPaginator(Article.objects.filter(id=0), 5)