summaryrefslogtreecommitdiff
path: root/tests/test_authcookie.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2015-10-15 21:59:42 +0200
committerMatěj Cepl <mcepl@cepl.eu>2015-10-17 21:00:31 +0200
commite097dab09207d3a54f6e933fa60d05b883ddfe08 (patch)
tree589dc7c2a0a78a1bc767ebc6c8dab45a5ea6498c /tests/test_authcookie.py
parent83ebd4803b5cd63d318645099fda219673b59b01 (diff)
downloadm2crypto-e097dab09207d3a54f6e933fa60d05b883ddfe08.tar.gz
Replace self.fail* with self.assert*
Negative logic makes it less readable.
Diffstat (limited to 'tests/test_authcookie.py')
-rw-r--r--tests/test_authcookie.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/tests/test_authcookie.py b/tests/test_authcookie.py
index 6cab990..53bffda 100644
--- a/tests/test_authcookie.py
+++ b/tests/test_authcookie.py
@@ -31,82 +31,82 @@ class AuthCookieTestCase(unittest.TestCase):
def test_mix_unmix(self):
dough = mix(self.exp, self.data)
exp, data = unmix(dough)
- self.failUnlessEqual(data, self.data)
- self.failUnlessEqual(exp, self.exp)
+ self.assertEqual(data, self.data)
+ self.assertEqual(exp, self.exp)
def test_make_cookie(self):
c = self.jar.makeCookie(self.exp, self.data)
- self.failUnless(isinstance(c, AuthCookie))
- self.failUnlessEqual(c.expiry(), self.exp)
- self.failUnlessEqual(c.data(), self.data)
+ self.assertTrue(isinstance(c, AuthCookie))
+ self.assertEqual(c.expiry(), self.exp)
+ self.assertEqual(c.data(), self.data)
# Peek inside the cookie jar...
key = self.jar._key
mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
- self.failUnlessEqual(c.mac(), mac)
+ self.assertEqual(c.mac(), mac)
# Ok, stop peeking now.
cookie_str = self._format % (repr(self.exp), self.data, mac)
- self.failUnlessEqual(c.output(), cookie_str)
+ self.assertEqual(c.output(), cookie_str)
def test_expired(self):
t = self.exp - 7200
c = self.jar.makeCookie(t, self.data)
- self.failUnless(c.isExpired())
+ self.assertTrue(c.isExpired())
def test_not_expired(self):
c = self.jar.makeCookie(self.exp, self.data)
- self.failIf(c.isExpired())
+ self.assertFalse(c.isExpired())
def test_is_valid(self):
c = self.jar.makeCookie(self.exp, self.data)
- self.failUnless(self.jar.isGoodCookie(c))
+ self.assertTrue(self.jar.isGoodCookie(c))
def test_is_invalid_expired(self):
t = self.exp - 7200
c = self.jar.makeCookie(t, self.data)
- self.failIf(self.jar.isGoodCookie(c))
+ self.assertFalse(self.jar.isGoodCookie(c))
def test_is_invalid_changed_exp(self):
c = self.jar.makeCookie(self.exp, self.data)
c._expiry = 'this is bad'
- self.failIf(self.jar.isGoodCookie(c))
+ self.assertFalse(self.jar.isGoodCookie(c))
def test_is_invalid_changed_data(self):
c = self.jar.makeCookie(self.exp, self.data)
c._data = 'this is bad'
- self.failIf(self.jar.isGoodCookie(c))
+ self.assertFalse(self.jar.isGoodCookie(c))
def test_is_invalid_changed_mac(self):
c = self.jar.makeCookie(self.exp, self.data)
c._mac = 'this is bad'
- self.failIf(self.jar.isGoodCookie(c))
+ self.assertFalse(self.jar.isGoodCookie(c))
def test_mix_unmix3(self):
c = self.jar.makeCookie(self.exp, self.data)
s = Cookie.SmartCookie()
s.load(c.output())
exp, data, digest = unmix3(s[self._token].value)
- self.failUnlessEqual(data, self.data)
- self.failUnlessEqual(float(exp), self.exp)
+ self.assertEqual(data, self.data)
+ self.assertEqual(float(exp), self.exp)
key = self.jar._key # Peeking...
mac = binascii.b2a_base64(EVP.hmac(key, mix(self.exp, self.data), 'sha1'))[:-1]
- self.failUnlessEqual(digest, mac)
+ self.assertEqual(digest, mac)
def test_cookie_str(self):
c = self.jar.makeCookie(self.exp, self.data)
- self.failUnless(self.jar.isGoodCookieString(c.output()))
+ self.assertTrue(self.jar.isGoodCookieString(c.output()))
def test_cookie_str2(self):
c = self.jar.makeCookie(self.exp, self.data)
s = Cookie.SmartCookie()
s.load(c.output())
- self.failUnless(self.jar.isGoodCookieString(s.output()))
+ self.assertTrue(self.jar.isGoodCookieString(s.output()))
def test_cookie_str_expired(self):
t = self.exp - 7200
c = self.jar.makeCookie(t, self.data)
s = Cookie.SmartCookie()
s.load(c.output())
- self.failIf(self.jar.isGoodCookieString(s.output()))
+ self.assertFalse(self.jar.isGoodCookieString(s.output()))
def test_cookie_str_arbitrary_change(self):
c = self.jar.makeCookie(self.exp, self.data)
@@ -114,7 +114,7 @@ class AuthCookieTestCase(unittest.TestCase):
str = cout[:32] + 'this is bad' + cout[32:]
s = Cookie.SmartCookie()
s.load(str)
- self.failIf(self.jar.isGoodCookieString(s.output()))
+ self.assertFalse(self.jar.isGoodCookieString(s.output()))
def test_cookie_str_changed_exp(self):
c = self.jar.makeCookie(self.exp, self.data)
@@ -122,7 +122,7 @@ class AuthCookieTestCase(unittest.TestCase):
str = cout[:26] + chr(ord(cout[26])^1) + cout[27:]
s = Cookie.SmartCookie()
s.load(str)
- self.failIf(self.jar.isGoodCookieString(s.output()))
+ self.assertFalse(self.jar.isGoodCookieString(s.output()))
def test_cookie_str_changed_data(self):
c = self.jar.makeCookie(self.exp, self.data)
@@ -130,7 +130,7 @@ class AuthCookieTestCase(unittest.TestCase):
str = cout[:36] + chr(ord(cout[36])^1) + cout[37:]
s = Cookie.SmartCookie()
s.load(str)
- self.failIf(self.jar.isGoodCookieString(s.output()))
+ self.assertFalse(self.jar.isGoodCookieString(s.output()))
def test_cookie_str_changed_mac(self):
c = self.jar.makeCookie(self.exp, self.data)
@@ -138,7 +138,7 @@ class AuthCookieTestCase(unittest.TestCase):
str = cout[:76] + chr(ord(cout[76])^1) + cout[77:]
s = Cookie.SmartCookie()
s.load(str)
- self.failIf(self.jar.isGoodCookieString(s.output()))
+ self.assertFalse(self.jar.isGoodCookieString(s.output()))
def suite():