|
1 | | -import sys |
2 | 1 | from collections import OrderedDict |
3 | 2 |
|
4 | | -import pytest |
5 | 3 | from rest_framework.request import Request |
6 | 4 | from rest_framework.test import APIRequestFactory |
7 | 5 | from rest_framework.utils.urls import replace_query_param |
@@ -78,72 +76,3 @@ def test_valid_offset_limit(self): |
78 | 76 |
|
79 | 77 | assert queryset == list(range(offset + 1, next_offset + 1)) |
80 | 78 | assert content == expected_content |
81 | | - |
82 | | - @pytest.mark.xfail((sys.version_info.major, sys.version_info.minor) == (2, 7), |
83 | | - reason="python2.7 fails to generate DeprecationWarrning for unknown reason") |
84 | | - def test_limit_offset_deprecation(self): |
85 | | - with pytest.warns(DeprecationWarning) as record: |
86 | | - pagination.LimitOffsetPagination() |
87 | | - assert len(record) == 1 |
88 | | - assert 'LimitOffsetPagination is deprecated' in str(record[0].message) |
89 | | - |
90 | | - class MyInheritedLimitOffsetPagination(pagination.LimitOffsetPagination): |
91 | | - """ |
92 | | - Inherit the default values |
93 | | - """ |
94 | | - pass |
95 | | - |
96 | | - class MyOverridenLimitOffsetPagination(pagination.LimitOffsetPagination): |
97 | | - """ |
98 | | - Explicitly set max_limit to the "old" values. |
99 | | - """ |
100 | | - max_limit = None |
101 | | - |
102 | | - def test_my_limit_offset_deprecation(self): |
103 | | - with pytest.warns(DeprecationWarning) as record: |
104 | | - self.MyInheritedLimitOffsetPagination() |
105 | | - assert len(record) == 1 |
106 | | - assert 'LimitOffsetPagination is deprecated' in str(record[0].message) |
107 | | - |
108 | | - with pytest.warns(None) as record: |
109 | | - self.MyOverridenLimitOffsetPagination() |
110 | | - assert len(record) == 0 |
111 | | - |
112 | | - |
113 | | -class TestPageNumber: |
114 | | - """ |
115 | | - Unit tests for `pagination.JsonApiPageNumberPagination`. |
116 | | - """ |
117 | | - |
118 | | - @pytest.mark.xfail((sys.version_info.major, sys.version_info.minor) == (2, 7), |
119 | | - reason="python2.7 fails to generate DeprecationWarrning for unknown reason") |
120 | | - def test_page_number_deprecation(self): |
121 | | - with pytest.warns(DeprecationWarning) as record: |
122 | | - pagination.PageNumberPagination() |
123 | | - assert len(record) == 1 |
124 | | - assert 'PageNumberPagination is deprecated' in str(record[0].message) |
125 | | - |
126 | | - class MyInheritedPageNumberPagination(pagination.PageNumberPagination): |
127 | | - """ |
128 | | - Inherit the default values |
129 | | - """ |
130 | | - pass |
131 | | - |
132 | | - class MyOverridenPageNumberPagination(pagination.PageNumberPagination): |
133 | | - """ |
134 | | - Explicitly set page_query_param and page_size_query_param to the "old" values. |
135 | | - """ |
136 | | - page_query_param = "page" |
137 | | - page_size_query_param = "page_size" |
138 | | - |
139 | | - @pytest.mark.xfail((sys.version_info.major, sys.version_info.minor) == (2, 7), |
140 | | - reason="python2.7 fails to generate DeprecationWarrning for unknown reason") |
141 | | - def test_my_page_number_deprecation(self): |
142 | | - with pytest.warns(DeprecationWarning) as record: |
143 | | - self.MyInheritedPageNumberPagination() |
144 | | - assert len(record) == 1 |
145 | | - assert 'PageNumberPagination is deprecated' in str(record[0].message) |
146 | | - |
147 | | - with pytest.warns(None) as record: |
148 | | - self.MyOverridenPageNumberPagination() |
149 | | - assert len(record) == 0 |
0 commit comments