ó
BwLc           @   s–   d  Z  d Z d d l Z d d l Z d d l Z d e f d „  ƒ  YZ d d d d d d „ Z i  d „ Z	 e
 d	 k r’ d
 „  Z e j d d ƒ n  d S(   sg   Self tests

These tests should perform quickly and can ideally be used every time an
application runs.
s   $Id$iÿÿÿÿNt   SelfTestErrorc           B   s   e  Z d  „  Z RS(   c         C   s)   t  j |  | | ƒ | |  _ | |  _ d  S(   N(   t	   Exceptiont   __init__t   messaget   result(   t   selfR   R   (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyR   &   s    	(   t   __name__t
   __module__R   (    (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyR    %   s   i    c   	      K   s  | d k r i  } n  t j ƒ  } |  d k r[ | d k rK t d | ƒ } n  | j | ƒ n4 | d k rƒ | j |  j d | ƒ ƒ n t d ƒ ‚ | d k r® t j ƒ  | d <n  t j d | |  } | j | ƒ } | j	 ƒ  s| d k rt
 j j | j ƒ  ƒ n  t d | ƒ ‚ n  | S(   s6  Execute self-tests.

    This raises SelfTestError if any test is unsuccessful.

    You may optionally pass in a sub-module of SelfTest if you only want to
    perform some of the tests.  For example, the following would test only the
    hash modules:

        Crypto.SelfTest.run(Crypto.SelfTest.Hash)

    t   configs5   'module' and 'tests' arguments are mutually exclusivet   streamt	   verbositys   Self-test failedN(   t   Nonet   unittestt	   TestSuitet	   get_testst   addTestst
   ValueErrort   StringIOt   TextTestRunnert   runt   wasSuccessfult   syst   stderrt   writet   getvalueR    (	   t   moduleR
   R	   t   testsR   t   kwargst   suitet   runnerR   (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyR   +   s&    	c         C   sÖ   g  } d d  l  } | | j d |  ƒ 7} d d  l } | | j d |  ƒ 7} d d  l } | | j d |  ƒ 7} d d  l } | | j d |  ƒ 7} d d  l } | | j d |  ƒ 7} d d  l } | | j d |  ƒ 7} | S(   NiÿÿÿÿR   (   t   CipherR   t   Hasht   Protocolt	   PublicKeyt   Randomt   Util(   R   R   R   R   R    R!   R"   R#   (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyR   M   s          t   __main__c           C   s   t  j t ƒ  ƒ S(   N(   R   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyt   <lambda>X   s    t   defaultTestR   (   t   __doc__t   __revision__R   R   R   R   R    R   R   R   R   R   t   main(    (    (    s<   /usr/lib/python2.7/dist-packages/Crypto/SelfTest/__init__.pyt   <module>   s   "
	