Changeset 391 for python/trunk/Lib/test/test_hmac.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_hmac.py
r2 r391 214 214 with warnings.catch_warnings(): 215 215 warnings.simplefilter('error', RuntimeWarning) 216 try:216 with self.assertRaises(RuntimeWarning): 217 217 hmac.HMAC('a', 'b', digestmod=MockCrazyHash) 218 except RuntimeWarning:219 pass220 else:221 218 self.fail('Expected warning about missing block_size') 222 219 223 220 MockCrazyHash.block_size = 1 224 try:221 with self.assertRaises(RuntimeWarning): 225 222 hmac.HMAC('a', 'b', digestmod=MockCrazyHash) 226 except RuntimeWarning:227 pass228 else:229 223 self.fail('Expected warning about small block_size') 230 224 … … 261 255 # NOTE: this whitebox test depends on the hmac class internals 262 256 h = hmac.HMAC("key") 263 self. failUnless(h.digest_cons == hashlib.md5)257 self.assertTrue(h.digest_cons == hashlib.md5) 264 258 265 259 def test_exercise_all_methods(self): … … 281 275 h1 = hmac.HMAC("key") 282 276 h2 = h1.copy() 283 self. failUnless(h1.digest_cons == h2.digest_cons,277 self.assertTrue(h1.digest_cons == h2.digest_cons, 284 278 "digest constructors don't match.") 285 self. failUnless(type(h1.inner) == type(h2.inner),279 self.assertTrue(type(h1.inner) == type(h2.inner), 286 280 "Types of inner don't match.") 287 self. failUnless(type(h1.outer) == type(h2.outer),281 self.assertTrue(type(h1.outer) == type(h2.outer), 288 282 "Types of outer don't match.") 289 283 … … 293 287 h2 = h1.copy() 294 288 # Using id() in case somebody has overridden __cmp__. 295 self. failUnless(id(h1) != id(h2), "No real copy of the HMAC instance.")296 self. failUnless(id(h1.inner) != id(h2.inner),289 self.assertTrue(id(h1) != id(h2), "No real copy of the HMAC instance.") 290 self.assertTrue(id(h1.inner) != id(h2.inner), 297 291 "No real copy of the attribute 'inner'.") 298 self. failUnless(id(h1.outer) != id(h2.outer),292 self.assertTrue(id(h1.outer) != id(h2.outer), 299 293 "No real copy of the attribute 'outer'.") 300 294 … … 304 298 h1.update("some random text") 305 299 h2 = h1.copy() 306 self. failUnless(h1.digest() == h2.digest(),300 self.assertTrue(h1.digest() == h2.digest(), 307 301 "Digest of copy doesn't match original digest.") 308 self. failUnless(h1.hexdigest() == h2.hexdigest(),302 self.assertTrue(h1.hexdigest() == h2.hexdigest(), 309 303 "Hexdigest of copy doesn't match original hexdigest.") 310 304
Note:
See TracChangeset
for help on using the changeset viewer.