Skip to content

Commit

Permalink
Merge pull request #609 from pfouque/fix_unittest
Browse files Browse the repository at this point in the history
Fix override_config test decorator on Django 5.2
  • Loading branch information
Natim authored Feb 4, 2025
2 parents 3a4071e + 8193866 commit 22bdb01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions constance/test/unittest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import wraps

from django import VERSION as DJANGO_VERSION
from django.test import SimpleTestCase
from django.test.utils import override_settings

Expand Down Expand Up @@ -44,9 +45,19 @@ def modify_test_case(self, test_case):
original_pre_setup = test_case._pre_setup
original_post_teardown = test_case._post_teardown

def _pre_setup(inner_self):
self.enable()
original_pre_setup(inner_self)
if DJANGO_VERSION < (5, 2):

def _pre_setup(inner_self):
self.enable()
original_pre_setup(inner_self)
else:

@classmethod
def _pre_setup(cls):
# NOTE: Django 5.2 turned this as a classmethod
# https://github.com/django/django/pull/18514/files
self.enable()
original_pre_setup()

def _post_teardown(inner_self):
original_post_teardown(inner_self)
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ envlist =
py{38,39,310,311,312}-dj{42}-{unittest,pytest,checkmigrations}
py{310,311,312}-dj{50}-{unittest,pytest,checkmigrations}
py{310,311,312,313}-dj{51}-{unittest,pytest,checkmigrations}
py{310,311,312,313}-dj{52}-{unittest,pytest,checkmigrations}
py{310,311,312,313}-dj{main}-{unittest,pytest,checkmigrations}
skip_missing_interpreters = True

Expand All @@ -14,6 +15,7 @@ deps =
dj42: django>=4.2,<4.3
dj50: django>=5.0,<5.1
dj51: django>=5.1,<5.2
dj52: django==5.2alpha1
djmain: https://github.com/django/django/archive/main.tar.gz
pytest: pytest
pytest: pytest-cov
Expand Down

0 comments on commit 22bdb01

Please # to comment.