From e6eca0daf8ae9d00ddc6531e3f2ae955c3a5723c Mon Sep 17 00:00:00 2001 From: Samuel Dion-Girardeau Date: Mon, 7 May 2018 21:20:54 -0400 Subject: [PATCH] Use assertion methods introduced in Python 2.7 Since Python 2.6 support was dropped, we can use all these: https://docs.python.org/2/library/unittest.html#assert-methods --- tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests.py b/tests.py index c5418af..17cd453 100644 --- a/tests.py +++ b/tests.py @@ -22,14 +22,14 @@ class SnapPassTestCase(TestCase): key = snappass.set_password(password, 30) self.assertEqual(password, snappass.get_password(key)) # Assert that we can't look this up a second time. - self.assertEqual(None, snappass.get_password(key)) + self.assertIsNone(snappass.get_password(key)) def test_password_is_not_stored_in_plaintext(self): password = "trustno1" token = snappass.set_password(password, 30) redis_key = token.split(snappass.TOKEN_SEPARATOR)[0] stored_password_text = snappass.redis_client.get(redis_key).decode('utf-8') - self.assertFalse(password in stored_password_text) + self.assertNotIn(password, stored_password_text) def test_returned_token_format(self): password = "trustsome1" @@ -97,7 +97,7 @@ class SnapPassTestCase(TestCase): # Expire functionality must be explicitly invoked using do_expire(time). # mockredis does not support automatic expiration at this time snappass.redis_client.do_expire() - self.assertEqual(None, snappass.get_password(key)) + self.assertIsNone(snappass.get_password(key)) class SnapPassRoutesTestCase(TestCase): @@ -110,7 +110,7 @@ class SnapPassRoutesTestCase(TestCase): password = "I like novelty kitten statues!" key = snappass.set_password(password, 30) rv = self.app.get('/{0}'.format(key)) - self.assertTrue(password in rv.get_data(as_text=True)) + self.assertIn(password, rv.get_data(as_text=True)) def test_bots_denial(self): """