|
1 | 1 | from datetime import datetime, timedelta
|
2 | 2 | from operator import attrgetter
|
3 | 3 |
|
| 4 | +import django |
4 | 5 | from django.contrib.auth import get_user_model
|
5 | 6 | from django.db import IntegrityError
|
6 | 7 | from django.test import TestCase, override_settings, skipUnlessDBFeature
|
@@ -198,10 +199,17 @@ def setUp(self):
|
198 | 199 | Poll(id=4, question="Question 4", pub_date=datetime.now()),
|
199 | 200 | ]
|
200 | 201 |
|
| 202 | + # DEV: Remove this method when the minimum required Django version is 4.2 |
| 203 | + def assertQuerySetEqual(self, *args, **kwargs): |
| 204 | + if django.VERSION < (4, 2): |
| 205 | + return self.assertQuerysetEqual(*args, **kwargs) |
| 206 | + else: |
| 207 | + return super().assertQuerySetEqual(*args, **kwargs) |
| 208 | + |
201 | 209 | def test_simple_bulk_history_create(self):
|
202 | 210 | created = Poll.history.bulk_history_create(self.data)
|
203 | 211 | self.assertEqual(len(created), 4)
|
204 |
| - self.assertQuerysetEqual( |
| 212 | + self.assertQuerySetEqual( |
205 | 213 | Poll.history.order_by("question"),
|
206 | 214 | ["Question 1", "Question 2", "Question 3", "Question 4"],
|
207 | 215 | attrgetter("question"),
|
@@ -326,10 +334,17 @@ def setUp(self):
|
326 | 334 | Poll(id=4, question="Question 4", pub_date=datetime.now()),
|
327 | 335 | ]
|
328 | 336 |
|
| 337 | + # DEV: Remove this method when the minimum required Django version is 4.2 |
| 338 | + def assertQuerySetEqual(self, *args, **kwargs): |
| 339 | + if django.VERSION < (4, 2): |
| 340 | + return self.assertQuerysetEqual(*args, **kwargs) |
| 341 | + else: |
| 342 | + return super().assertQuerySetEqual(*args, **kwargs) |
| 343 | + |
329 | 344 | def test_simple_bulk_history_create(self):
|
330 | 345 | created = Poll.history.bulk_history_create(self.data, update=True)
|
331 | 346 | self.assertEqual(len(created), 4)
|
332 |
| - self.assertQuerysetEqual( |
| 347 | + self.assertQuerySetEqual( |
333 | 348 | Poll.history.order_by("question"),
|
334 | 349 | ["Question 1", "Question 2", "Question 3", "Question 4"],
|
335 | 350 | attrgetter("question"),
|
|
0 commit comments