summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-22 19:38:14 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-22 19:38:14 (GMT)
commit7e8fdba01cdc1abad79a7bf0d457e610d08eb7b8 (patch)
treeb08fd7fa16fbc0e2f8c4843edea8a7491b0aa028
parentcb682584a3aa4057f9df53db188b7e163b8db58b (diff)
downloadcpython-7e8fdba01cdc1abad79a7bf0d457e610d08eb7b8.zip
cpython-7e8fdba01cdc1abad79a7bf0d457e610d08eb7b8.tar.gz
cpython-7e8fdba01cdc1abad79a7bf0d457e610d08eb7b8.tar.bz2
Standardize behavior: no docstrings in test functions; create a single
suite merging all test cases.
-rw-r--r--Lib/test/test_hmac.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index f9cd73e..f36db4e 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -3,8 +3,9 @@ import unittest
from test import test_support
class TestVectorsTestCase(unittest.TestCase):
+
def test_vectors(self):
- """Test the HMAC module against test vectors from the RFC."""
+ # Test the HMAC module against test vectors from the RFC.
def md5test(key, data, digest):
h = hmac.HMAC(key, data)
@@ -23,8 +24,9 @@ class TestVectorsTestCase(unittest.TestCase):
"56be34521d144c88dbb8c733f0e8b3f6")
class ConstructorTestCase(unittest.TestCase):
+
def test_normal(self):
- """Standard constructor call."""
+ # Standard constructor call.
failed = 0
try:
h = hmac.HMAC("key")
@@ -32,14 +34,14 @@ class ConstructorTestCase(unittest.TestCase):
self.fail("Standard constructor call raised exception.")
def test_withtext(self):
- """Constructor call with text."""
+ # Constructor call with text.
try:
h = hmac.HMAC("key", "hash this!")
except:
self.fail("Constructor call with text argument raised exception.")
def test_withmodule(self):
- """Constructor call with text and digest module."""
+ # Constructor call with text and digest module.
import sha
try:
h = hmac.HMAC("key", "", sha)
@@ -47,14 +49,15 @@ class ConstructorTestCase(unittest.TestCase):
self.fail("Constructor call with sha module raised exception.")
class SanityTestCase(unittest.TestCase):
+
def test_default_is_md5(self):
- """Testing if HMAC defaults to MD5 algorithm."""
+ # Testing if HMAC defaults to MD5 algorithm.
import md5
h = hmac.HMAC("key")
self.failUnless(h.digestmod == md5)
def test_exercise_all_methods(self):
- """Exercising all methods once."""
+ # Exercising all methods once.
# This must not raise any exceptions
try:
h = hmac.HMAC("my secret key")
@@ -66,8 +69,9 @@ class SanityTestCase(unittest.TestCase):
self.fail("Exception raised during normal usage of HMAC class.")
class CopyTestCase(unittest.TestCase):
+
def test_attributes(self):
- """Testing if attributes are of same type."""
+ # Testing if attributes are of same type.
h1 = hmac.HMAC("key")
h2 = h1.copy()
self.failUnless(h1.digestmod == h2.digestmod,
@@ -78,7 +82,7 @@ class CopyTestCase(unittest.TestCase):
"Types of outer don't match.")
def test_realcopy(self):
- """Testing if the copy method created a real copy."""
+ # Testing if the copy method created a real copy.
h1 = hmac.HMAC("key")
h2 = h1.copy()
# Using id() in case somebody has overridden __cmp__.
@@ -89,7 +93,7 @@ class CopyTestCase(unittest.TestCase):
"No real copy of the attribute 'outer'.")
def test_equality(self):
- """Testing if the copy has the same digests."""
+ # Testing if the copy has the same digests.
h1 = hmac.HMAC("key")
h1.update("some random text")
h2 = h1.copy()
@@ -99,10 +103,12 @@ class CopyTestCase(unittest.TestCase):
"Hexdigest of copy doesn't match original hexdigest.")
def test_main():
- test_support.run_unittest(TestVectorsTestCase)
- test_support.run_unittest(ConstructorTestCase)
- test_support.run_unittest(SanityTestCase)
- test_support.run_unittest(CopyTestCase)
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestVectorsTestCase))
+ suite.addTest(unittest.makeSuite(ConstructorTestCase))
+ suite.addTest(unittest.makeSuite(SanityTestCase))
+ suite.addTest(unittest.makeSuite(CopyTestCase))
+ test_support.run_suite(suite)
if __name__ == "__main__":
test_main()