Skip to content

Commit 22bdb01

Browse files
authored
Merge pull request #609 from pfouque/fix_unittest
Fix override_config test decorator on Django 5.2
2 parents 3a4071e + 8193866 commit 22bdb01

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

constance/test/unittest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import wraps
22

3+
from django import VERSION as DJANGO_VERSION
34
from django.test import SimpleTestCase
45
from django.test.utils import override_settings
56

@@ -44,9 +45,19 @@ def modify_test_case(self, test_case):
4445
original_pre_setup = test_case._pre_setup
4546
original_post_teardown = test_case._post_teardown
4647

47-
def _pre_setup(inner_self):
48-
self.enable()
49-
original_pre_setup(inner_self)
48+
if DJANGO_VERSION < (5, 2):
49+
50+
def _pre_setup(inner_self):
51+
self.enable()
52+
original_pre_setup(inner_self)
53+
else:
54+
55+
@classmethod
56+
def _pre_setup(cls):
57+
# NOTE: Django 5.2 turned this as a classmethod
58+
# https://github.com/django/django/pull/18514/files
59+
self.enable()
60+
original_pre_setup()
5061

5162
def _post_teardown(inner_self):
5263
original_post_teardown(inner_self)

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ envlist =
44
py{38,39,310,311,312}-dj{42}-{unittest,pytest,checkmigrations}
55
py{310,311,312}-dj{50}-{unittest,pytest,checkmigrations}
66
py{310,311,312,313}-dj{51}-{unittest,pytest,checkmigrations}
7+
py{310,311,312,313}-dj{52}-{unittest,pytest,checkmigrations}
78
py{310,311,312,313}-dj{main}-{unittest,pytest,checkmigrations}
89
skip_missing_interpreters = True
910

@@ -14,6 +15,7 @@ deps =
1415
dj42: django>=4.2,<4.3
1516
dj50: django>=5.0,<5.1
1617
dj51: django>=5.1,<5.2
18+
dj52: django==5.2alpha1
1719
djmain: https://github.com/django/django/archive/main.tar.gz
1820
pytest: pytest
1921
pytest: pytest-cov

0 commit comments

Comments
 (0)