Skip to content

Commit 9214ed2

Browse files
committed
fix: patch assertQuerysetEqual
1 parent 38587e3 commit 9214ed2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/runtests.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.conf import settings
77
from django.test.utils import get_runner
88

9-
from clickhouse_backend.compat import dj_ge4
9+
from clickhouse_backend import compat
1010

1111
RUNTESTS_DIR = os.path.abspath(os.path.dirname(__file__))
1212
SKIP_DIRS = ["unsupported"]
@@ -31,12 +31,13 @@ def get_test_modules():
3131

3232
# assertQuerysetEqual is removed from django 5.1
3333
def patch_assertQuerysetEqual():
34-
from django.test import TransactionTestCase
34+
if compat.dj_ge5:
35+
from django.test import TransactionTestCase
3536

36-
def assertQuerysetEqual(self, *args, **kw):
37-
return self.assertQuerySetEqual(*args, **kw)
37+
def assertQuerysetEqual(self, *args, **kw):
38+
return self.assertQuerySetEqual(*args, **kw)
3839

39-
TransactionTestCase.assertQuerysetEqual = assertQuerysetEqual
40+
TransactionTestCase.assertQuerysetEqual = assertQuerysetEqual
4041

4142

4243
if __name__ == "__main__":
@@ -78,7 +79,7 @@ def assertQuerysetEqual(self, *args, **kw):
7879
action="store_true",
7980
help="Turn on the SQL query logger within tests.",
8081
)
81-
if not dj_ge4:
82+
if not compat.dj_ge4:
8283
from django.test.runner import default_test_processes
8384

8485
parser.add_argument(
@@ -114,7 +115,7 @@ def assertQuerysetEqual(self, *args, **kw):
114115
django.setup()
115116

116117
parallel = options.parallel
117-
if dj_ge4 and parallel in {0, "auto"}:
118+
if compat.dj_ge4 and parallel in {0, "auto"}:
118119
# This doesn't work before django.setup() on some databases.
119120
from django.db import connections
120121
from django.test.runner import get_max_test_processes

0 commit comments

Comments
 (0)