[PATCH 1/2] tests: Replace 'force_login' with 'login'

Stephen Finucane stephen at that.guru
Sat Dec 24 06:43:34 AEDT 2016


The former is only available in Django 1.9+.

Signed-off-by: Stephen Finucane <stephen at that.guru>
Fixes: ed5e93242 ("tests: Add rudimentary pagination tests")
---
 patchwork/tests/test_paginator.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/patchwork/tests/test_paginator.py b/patchwork/tests/test_paginator.py
index b25ae1f..8597f6a 100644
--- a/patchwork/tests/test_paginator.py
+++ b/patchwork/tests/test_paginator.py
@@ -48,7 +48,8 @@ class PaginatorTest(TestCase):
         self.assertEqual(len(response.context['page'].object_list),
                          len(self.patches))
 
-        self.client.force_login(self.user)
+        self.client.login(username=self.user.username,
+                          password=self.user.username)
         response = self._get_patches({})
         self.assertEqual(response.status_code, 200)
         self.assertEqual(len(response.context['page'].object_list),
@@ -56,7 +57,8 @@ class PaginatorTest(TestCase):
 
     def test_page_valid(self):
         page = 2
-        self.client.force_login(self.user)
+        self.client.login(username=self.user.username,
+                          password=self.user.username)
 
         for page_ in [2, str(2)]:
             response = self._get_patches({'page': page_})
@@ -65,7 +67,8 @@ class PaginatorTest(TestCase):
                              self.patches[-page].id)
 
     def test_page_invalid(self):
-        self.client.force_login(self.user)
+        self.client.login(username=self.user.username,
+                          password=self.user.username)
         response = self._get_patches({'page': 'foo'})
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.context['page'].object_list[0].id,
-- 
2.9.3



More information about the Patchwork mailing list