@@ -26,6 +26,19 @@ def test_order_by(self):
26
26
27
27
28
28
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
+
29
42
def test_default (self ):
30
43
request = Mock (spec_set = ['GET' , 'session' ])
31
44
request .session = {}
@@ -38,7 +51,7 @@ def test_default(self):
38
51
'options_order_by' : RequestsView ().options_order_by ,
39
52
'options_order_dir' : RequestsView ().options_order_dir ,
40
53
}, context ))
41
- self .assertQuerysetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
54
+ self .assertQuerySetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
42
55
self .assertNotIn ('path' , context )
43
56
self .assertIn ('results' , context )
44
57
@@ -60,7 +73,7 @@ def test_get(self):
60
73
'options_order_by' : RequestsView ().options_order_by ,
61
74
'options_order_dir' : RequestsView ().options_order_dir ,
62
75
}, context ))
63
- self .assertQuerysetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
76
+ self .assertQuerySetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
64
77
self .assertIn ('results' , context )
65
78
66
79
def test_post (self ):
@@ -74,7 +87,7 @@ def test_post(self):
74
87
'overalltime' : {'typ' : 'TimeSpentOnQueriesFilter' , 'value' : 100 , 'str' : 'DB Time >= 100' }
75
88
},
76
89
}, context ))
77
- self .assertQuerysetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
90
+ self .assertQuerySetEqual (context ['options_paths' ], RequestsView ()._get_paths ())
78
91
self .assertIn ('results' , context )
79
92
80
93
def test_view_without_session_and_auth_middlewares (self ):
0 commit comments