Loading django/contrib/auth/tests/test_context_processors.py +4 −4 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ class PermWrapperTests(TestCase): """ perms = PermWrapper(MockUser()) # Works for modules and full permissions. self.assertTrue('mockapp' in perms) self.assertFalse('nonexisting' in perms) self.assertTrue('mockapp.someperm' in perms) self.assertFalse('mockapp.nonexisting' in perms) self.assertIn('mockapp', perms) self.assertNotIn('nonexisting', perms) self.assertIn('mockapp.someperm', perms) self.assertNotIn('mockapp.nonexisting', perms) def test_permlookupdict_in(self): """ Loading django/contrib/auth/tests/test_decorators.py +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ class LoginRequiredTestCase(AuthViewsTestCase): login_url = settings.LOGIN_URL response = self.client.get(view_url) self.assertEqual(response.status_code, 302) self.assertTrue(login_url in response.url) self.assertIn(login_url, response.url) self.login() response = self.client.get(view_url) self.assertEqual(response.status_code, 200) Loading django/contrib/auth/tests/test_handlers.py +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase): User.objects.create_user('test', 'test@example.com', 'test') # User not in database self.assertTrue(check_password({}, 'unknown', '') is None) self.assertIsNone(check_password({}, 'unknown', '')) # Valid user with correct password self.assertTrue(check_password({}, 'test', 'test')) Loading @@ -53,7 +53,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase): CustomUser._default_manager.create_user('test@example.com', '1990-01-01', 'test') # User not in database self.assertTrue(check_password({}, 'unknown', '') is None) self.assertIsNone(check_password({}, 'unknown', '')) # Valid user with correct password' self.assertTrue(check_password({}, 'test@example.com', 'test')) Loading django/contrib/auth/tests/test_signals.py +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SignalTestCase(TestCase): self.assertEqual(len(self.login_failed), 1) self.assertEqual(self.login_failed[0]['username'], 'testclient') # verify the password is cleansed self.assertTrue('***' in self.login_failed[0]['password']) self.assertIn('***', self.login_failed[0]['password']) # Like this: self.client.login(username='testclient', password='password') Loading django/contrib/auth/tests/test_views.py +14 −16 Original line number Diff line number Diff line Loading @@ -55,13 +55,13 @@ class AuthViewsTestCase(TestCase): 'username': username, 'password': password, }) self.assertTrue(SESSION_KEY in self.client.session) self.assertIn(SESSION_KEY, self.client.session) return response def logout(self): response = self.client.get('/admin/logout/') self.assertEqual(response.status_code, 200) self.assertTrue(SESSION_KEY not in self.client.session) self.assertNotIn(SESSION_KEY, self.client.session) def assertFormError(self, response, error): """Assert that error is found in response.context['form'] errors""" Loading Loading @@ -129,7 +129,7 @@ class PasswordResetTest(AuthViewsTestCase): response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://" in mail.outbox[0].body) self.assertIn("http://", mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) # optional multipart text/html email has been added. Make sure original, # default functionality is 100% the same Loading @@ -148,8 +148,8 @@ class PasswordResetTest(AuthViewsTestCase): self.assertTrue(message.is_multipart()) self.assertEqual(message.get_payload(0).get_content_type(), 'text/plain') self.assertEqual(message.get_payload(1).get_content_type(), 'text/html') self.assertTrue('<html>' not in message.get_payload(0).get_payload()) self.assertTrue('<html>' in message.get_payload(1).get_payload()) self.assertNotIn('<html>', message.get_payload(0).get_payload()) self.assertIn('<html>', message.get_payload(1).get_payload()) def test_email_found_custom_from(self): "Email is sent if a valid email address is provided for password reset when a custom from_email is provided." Loading @@ -169,7 +169,7 @@ class PasswordResetTest(AuthViewsTestCase): ) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://adminsite.com" in mail.outbox[0].body) self.assertIn("http://adminsite.com", mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) # Skip any 500 handler action (like sending more mail...) Loading Loading @@ -215,7 +215,7 @@ class PasswordResetTest(AuthViewsTestCase): def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") self.assertIsNotNone(urlmatch, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid(self): Loading Loading @@ -346,7 +346,7 @@ class CustomUserPasswordResetTest(AuthViewsTestCase): def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") self.assertIsNotNone(urlmatch, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid_custom_user(self): Loading Loading @@ -502,7 +502,7 @@ class LoginTest(AuthViewsTestCase): 'password': password, }) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response.url, self.assertNotIn(bad_url, response.url, "%s should be blocked" % bad_url) # These URLs *should* still pass the security check Loading @@ -524,8 +524,7 @@ class LoginTest(AuthViewsTestCase): 'password': password, }) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response.url, "%s should be allowed" % good_url) self.assertIn(good_url, response.url, "%s should be allowed" % good_url) def test_login_form_contains_request(self): # 15198 Loading Loading @@ -683,7 +682,7 @@ class LoginRedirectUrlTest(AuthViewsTestCase): class LogoutTest(AuthViewsTestCase): def confirm_logged_out(self): self.assertTrue(SESSION_KEY not in self.client.session) self.assertNotIn(SESSION_KEY, self.client.session) def test_logout_default(self): "Logout without next_page option renders the default template" Loading @@ -696,7 +695,7 @@ class LogoutTest(AuthViewsTestCase): # Bug 14377 self.login() response = self.client.get('/logout/') self.assertTrue('site' in response.context) self.assertIn('site', response.context) def test_logout_with_overridden_redirect_url(self): # Bug 11223 Loading Loading @@ -762,7 +761,7 @@ class LogoutTest(AuthViewsTestCase): self.login() response = self.client.get(nasty_url) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response.url, self.assertNotIn(bad_url, response.url, "%s should be blocked" % bad_url) self.confirm_logged_out() Loading @@ -783,8 +782,7 @@ class LogoutTest(AuthViewsTestCase): self.login() response = self.client.get(safe_url) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response.url, "%s should be allowed" % good_url) self.assertIn(good_url, response.url, "%s should be allowed" % good_url) self.confirm_logged_out() def test_logout_preserve_language(self): Loading Loading
django/contrib/auth/tests/test_context_processors.py +4 −4 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ class PermWrapperTests(TestCase): """ perms = PermWrapper(MockUser()) # Works for modules and full permissions. self.assertTrue('mockapp' in perms) self.assertFalse('nonexisting' in perms) self.assertTrue('mockapp.someperm' in perms) self.assertFalse('mockapp.nonexisting' in perms) self.assertIn('mockapp', perms) self.assertNotIn('nonexisting', perms) self.assertIn('mockapp.someperm', perms) self.assertNotIn('mockapp.nonexisting', perms) def test_permlookupdict_in(self): """ Loading
django/contrib/auth/tests/test_decorators.py +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ class LoginRequiredTestCase(AuthViewsTestCase): login_url = settings.LOGIN_URL response = self.client.get(view_url) self.assertEqual(response.status_code, 302) self.assertTrue(login_url in response.url) self.assertIn(login_url, response.url) self.login() response = self.client.get(view_url) self.assertEqual(response.status_code, 200) Loading
django/contrib/auth/tests/test_handlers.py +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase): User.objects.create_user('test', 'test@example.com', 'test') # User not in database self.assertTrue(check_password({}, 'unknown', '') is None) self.assertIsNone(check_password({}, 'unknown', '')) # Valid user with correct password self.assertTrue(check_password({}, 'test', 'test')) Loading @@ -53,7 +53,7 @@ class ModWsgiHandlerTestCase(TransactionTestCase): CustomUser._default_manager.create_user('test@example.com', '1990-01-01', 'test') # User not in database self.assertTrue(check_password({}, 'unknown', '') is None) self.assertIsNone(check_password({}, 'unknown', '')) # Valid user with correct password' self.assertTrue(check_password({}, 'test@example.com', 'test')) Loading
django/contrib/auth/tests/test_signals.py +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SignalTestCase(TestCase): self.assertEqual(len(self.login_failed), 1) self.assertEqual(self.login_failed[0]['username'], 'testclient') # verify the password is cleansed self.assertTrue('***' in self.login_failed[0]['password']) self.assertIn('***', self.login_failed[0]['password']) # Like this: self.client.login(username='testclient', password='password') Loading
django/contrib/auth/tests/test_views.py +14 −16 Original line number Diff line number Diff line Loading @@ -55,13 +55,13 @@ class AuthViewsTestCase(TestCase): 'username': username, 'password': password, }) self.assertTrue(SESSION_KEY in self.client.session) self.assertIn(SESSION_KEY, self.client.session) return response def logout(self): response = self.client.get('/admin/logout/') self.assertEqual(response.status_code, 200) self.assertTrue(SESSION_KEY not in self.client.session) self.assertNotIn(SESSION_KEY, self.client.session) def assertFormError(self, response, error): """Assert that error is found in response.context['form'] errors""" Loading Loading @@ -129,7 +129,7 @@ class PasswordResetTest(AuthViewsTestCase): response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://" in mail.outbox[0].body) self.assertIn("http://", mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) # optional multipart text/html email has been added. Make sure original, # default functionality is 100% the same Loading @@ -148,8 +148,8 @@ class PasswordResetTest(AuthViewsTestCase): self.assertTrue(message.is_multipart()) self.assertEqual(message.get_payload(0).get_content_type(), 'text/plain') self.assertEqual(message.get_payload(1).get_content_type(), 'text/html') self.assertTrue('<html>' not in message.get_payload(0).get_payload()) self.assertTrue('<html>' in message.get_payload(1).get_payload()) self.assertNotIn('<html>', message.get_payload(0).get_payload()) self.assertIn('<html>', message.get_payload(1).get_payload()) def test_email_found_custom_from(self): "Email is sent if a valid email address is provided for password reset when a custom from_email is provided." Loading @@ -169,7 +169,7 @@ class PasswordResetTest(AuthViewsTestCase): ) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://adminsite.com" in mail.outbox[0].body) self.assertIn("http://adminsite.com", mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) # Skip any 500 handler action (like sending more mail...) Loading Loading @@ -215,7 +215,7 @@ class PasswordResetTest(AuthViewsTestCase): def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") self.assertIsNotNone(urlmatch, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid(self): Loading Loading @@ -346,7 +346,7 @@ class CustomUserPasswordResetTest(AuthViewsTestCase): def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") self.assertIsNotNone(urlmatch, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid_custom_user(self): Loading Loading @@ -502,7 +502,7 @@ class LoginTest(AuthViewsTestCase): 'password': password, }) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response.url, self.assertNotIn(bad_url, response.url, "%s should be blocked" % bad_url) # These URLs *should* still pass the security check Loading @@ -524,8 +524,7 @@ class LoginTest(AuthViewsTestCase): 'password': password, }) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response.url, "%s should be allowed" % good_url) self.assertIn(good_url, response.url, "%s should be allowed" % good_url) def test_login_form_contains_request(self): # 15198 Loading Loading @@ -683,7 +682,7 @@ class LoginRedirectUrlTest(AuthViewsTestCase): class LogoutTest(AuthViewsTestCase): def confirm_logged_out(self): self.assertTrue(SESSION_KEY not in self.client.session) self.assertNotIn(SESSION_KEY, self.client.session) def test_logout_default(self): "Logout without next_page option renders the default template" Loading @@ -696,7 +695,7 @@ class LogoutTest(AuthViewsTestCase): # Bug 14377 self.login() response = self.client.get('/logout/') self.assertTrue('site' in response.context) self.assertIn('site', response.context) def test_logout_with_overridden_redirect_url(self): # Bug 11223 Loading Loading @@ -762,7 +761,7 @@ class LogoutTest(AuthViewsTestCase): self.login() response = self.client.get(nasty_url) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response.url, self.assertNotIn(bad_url, response.url, "%s should be blocked" % bad_url) self.confirm_logged_out() Loading @@ -783,8 +782,7 @@ class LogoutTest(AuthViewsTestCase): self.login() response = self.client.get(safe_url) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response.url, "%s should be allowed" % good_url) self.assertIn(good_url, response.url, "%s should be allowed" % good_url) self.confirm_logged_out() def test_logout_preserve_language(self): Loading