Skip to content

Commit f4592c2

Browse files
committed
Update how APITestCase's client is set for django>=5.2 compatibility
1 parent a7cfbb2 commit f4592c2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test_plus/test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,13 @@ def __init__(self, *args, **kwargs):
375375

376376

377377
class APITestCase(TestCase):
378-
def __init__(self, *args, **kwargs):
379-
self.client_class = get_api_client()
380-
super(APITestCase, self).__init__(*args, **kwargs)
381378

382379

380+
def setUp(self):
381+
super(APITestCase, self).setUp()
382+
api_client_class = get_api_client()
383+
self.client = api_client_class()
384+
383385
# Note this class inherits from TestCase defined above.
384386
class CBVTestCase(TestCase):
385387
"""

test_project/test_app/tests/test_unittests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,10 @@ def test_get_with_non_primitive_data_type(self):
684684
assert response["content-type"] == "application/json"
685685
self.response_200()
686686

687+
def test_force_authenticate(self):
688+
u1 = self.make_user()
689+
self.client.force_authenticate(u1)
690+
687691

688692
# pytest tests
689693
def test_tp_loads(tp):

0 commit comments

Comments
 (0)