Skip to content

Commit 3028f34

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

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

test_plus/test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,11 @@ 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

379+
def setUp(self):
380+
super(APITestCase, self).setUp()
381+
api_client_class = get_api_client()
382+
self.client = api_client_class()
382383

383384
# Note this class inherits from TestCase defined above.
384385
class CBVTestCase(TestCase):

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)