__init__.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. #
  3. # SelfTest/Hash/__init__.py: Self-test for hash modules
  4. #
  5. # Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
  6. #
  7. # ===================================================================
  8. # The contents of this file are dedicated to the public domain. To
  9. # the extent that dedication to the public domain is not available,
  10. # everyone is granted a worldwide, perpetual, royalty-free,
  11. # non-exclusive license to exercise all rights associated with the
  12. # contents of this file for any purpose whatsoever.
  13. # No rights are reserved.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. # SOFTWARE.
  23. # ===================================================================
  24. """Self-test for hash modules"""
  25. __revision__ = "$Id$"
  26. def get_tests(config={}):
  27. tests = []
  28. from Crypto.SelfTest.Hash import test_HMAC; tests += test_HMAC.get_tests(config=config)
  29. from Crypto.SelfTest.Hash import test_MD2; tests += test_MD2.get_tests(config=config)
  30. from Crypto.SelfTest.Hash import test_MD4; tests += test_MD4.get_tests(config=config)
  31. from Crypto.SelfTest.Hash import test_MD5; tests += test_MD5.get_tests(config=config)
  32. from Crypto.SelfTest.Hash import test_RIPEMD; tests += test_RIPEMD.get_tests(config=config)
  33. from Crypto.SelfTest.Hash import test_SHA; tests += test_SHA.get_tests(config=config)
  34. from Crypto.SelfTest.Hash import test_SHA256; tests += test_SHA256.get_tests(config=config)
  35. try:
  36. from Crypto.SelfTest.Hash import test_SHA224; tests += test_SHA224.get_tests(config=config)
  37. from Crypto.SelfTest.Hash import test_SHA384; tests += test_SHA384.get_tests(config=config)
  38. from Crypto.SelfTest.Hash import test_SHA512; tests += test_SHA512.get_tests(config=config)
  39. except ImportError:
  40. import sys
  41. sys.stderr.write("SelfTest: warning: not testing SHA224/SHA384/SHA512 modules (not available)\n")
  42. return tests
  43. if __name__ == '__main__':
  44. import unittest
  45. suite = lambda: unittest.TestSuite(get_tests())
  46. unittest.main(defaultTest='suite')
  47. # vim:set ts=4 sw=4 sts=4 expandtab: