Skip to content

Commit ffc64e9

Browse files
authored
Merge pull request #732 from albertyw/django-5.1
Test against Django 5.1
2 parents dfb2826 + b122a8c commit ffc64e9

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.github/workflows/test.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
13-
django-version: ['3.2', '4.2', '5.0', 'main']
13+
django-version: ['3.2', '4.2', '5.0', '5.1', 'main']
1414
postgres-version: ['12', '16']
1515
mariadb-version: ['10.6', '10.11', '11.2']
1616
exclude:
@@ -26,6 +26,24 @@ jobs:
2626
- python-version: '3.9'
2727
django-version: '5.0'
2828

29+
# Django 5.1 doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
30+
- python-version: '3.8'
31+
django-version: '5.1'
32+
- python-version: '3.9'
33+
django-version: '5.1'
34+
35+
# Django 5.1 doesn't support PostgreSQL 12 (https://docs.djangoproject.com/en/5.1/releases/5.1/#dropped-support-for-postgresql-12)
36+
- django-version: '5.1'
37+
postgres-version: '12'
38+
- django-version: 'main'
39+
postgres-version: '12'
40+
41+
# Django main doesn't support python <=3.9 (https://docs.djangoproject.com/en/5.1/faq/install/)
42+
- python-version: '3.8'
43+
django-version: 'main'
44+
- python-version: '3.9'
45+
django-version: 'main'
46+
2947
# only test Django dev with PostgreSQL 12 and MariaDB 10.4
3048
- django-version: '3.2'
3149
postgres-version: '12'

project/tests/test_view_requests.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ def test_order_by(self):
2626

2727

2828
class TestContext(TestCase):
29+
def assertQuerySetEqual(self, *args, **kwargs):
30+
"""
31+
A shim for QuerySetEqual to enable support for multiple versions of Django
32+
TODO: delete this after support for Django 3.2 is dropped
33+
Reference: https://docs.djangoproject.com/en/5.0/topics/testing/tools/#django.test.TransactionTestCase.assertQuerySetEqual
34+
"""
35+
if hasattr(super(), 'assertQuerySetEqual'):
36+
# Django > 3.2
37+
super().assertQuerySetEqual(*args, **kwargs)
38+
else:
39+
# Django < 5.1
40+
super().assertQuerysetEqual(*args, **kwargs)
41+
2942
def test_default(self):
3043
request = Mock(spec_set=['GET', 'session'])
3144
request.session = {}
@@ -38,7 +51,7 @@ def test_default(self):
3851
'options_order_by': RequestsView().options_order_by,
3952
'options_order_dir': RequestsView().options_order_dir,
4053
}, context))
41-
self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths())
54+
self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths())
4255
self.assertNotIn('path', context)
4356
self.assertIn('results', context)
4457

@@ -60,7 +73,7 @@ def test_get(self):
6073
'options_order_by': RequestsView().options_order_by,
6174
'options_order_dir': RequestsView().options_order_dir,
6275
}, context))
63-
self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths())
76+
self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths())
6477
self.assertIn('results', context)
6578

6679
def test_post(self):
@@ -74,7 +87,7 @@ def test_post(self):
7487
'overalltime': {'typ': 'TimeSpentOnQueriesFilter', 'value': 100, 'str': 'DB Time >= 100'}
7588
},
7689
}, context))
77-
self.assertQuerysetEqual(context['options_paths'], RequestsView()._get_paths())
90+
self.assertQuerySetEqual(context['options_paths'], RequestsView()._get_paths())
7891
self.assertIn('results', context)
7992

8093
def test_view_without_session_and_auth_middlewares(self):

tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ DJANGO =
1111
3.2: dj32
1212
4.2: dj42
1313
5.0: dj50
14+
5.1: dj51
1415
main: djmain
1516

1617
[tox]
1718
envlist =
1819
py{38,39,310}-dj32-{sqlite3,mysql,postgresql}
19-
py{38,39,310,311}-dj{41,42,50,main}-{sqlite3,mysql,postgresql}
20-
py312-dj{42,50,main}-{sqlite3,mysql,postgresql}
20+
py{38,39,310,311,312}-dj42-{sqlite3,mysql,postgresql}
21+
py{310,311,312}-dj{50,51,main}-{sqlite3,mysql,postgresql}
2122

2223
[testenv]
2324
usedevelop = True
@@ -31,6 +32,7 @@ deps =
3132
dj32: django>=3.2,<3.3
3233
dj42: django>=4.2,<4.3
3334
dj50: django>=5.0,<5.1
35+
dj51: django>=5.1,<5.2
3436
djmain: https://github.com/django/django/archive/main.tar.gz
3537
py312: setuptools
3638
setenv =

0 commit comments

Comments
 (0)