mò
­fIc           @   sY  d  Z  e d j o e d ‚ n d k Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d Z	 d Z d a d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d d d „ Z d Z d „  Z y e d Z Wn e j
 o d Z n Xe i i d ƒ Z d k Z e i d j o
 d Z nÏ e i d j o
 d Z nµ d Z e o§ e d e ƒ o
 d Z  n e d d ƒ Z  e i! ƒ  Z" e# e d  ƒ p e i$ ƒ  d! d" j  o
 d Z% qe& d# ƒ Z% y e% i' d$ ƒ Wn e( j
 o qXd% e% GHn d Z) y e* e d& ƒ Z) Wni e+ j
 o] e i, i- d' e ƒ Z. y e* e. d& ƒ Z) e. Z [. Wqœe+ j
 o d( e e. f GHqœXn Xe) d j	 o) e) i/ ƒ  y e i0 e ƒ WqÒqÒXn [ [) d) k l0 Z0 e1 d* „ Z2 d+ d, „ Z3 d- „  Z4 d. „  Z5 d/ „  Z6 d k7 Z7 d0 f  d1 „  ƒ  YZ8 d d2 „ Z9 d3 „  Z: d d4 „ Z; d S(5   s7   Supporting definitions for the Python regression tests.s   test.test_supports3   test_support must be imported from the test packageNt   Errorc           B   s   t  Z d  Z RS(   s*   Base class for regression test exceptions.(   t   __name__t
   __module__t   __doc__(    (    (    t.   /mit/python/lib/python2.4/test/test_support.pyR       s   t
   TestFailedc           B   s   t  Z d  Z RS(   s   Test failed.(   R   R   R   (    (    (    R   R      s   t   TestSkippedc           B   s   t  Z d  Z RS(   s!  Test skipped.

    This can be raised to indicate that a test was deliberatly
    skipped, but not because a feature wasn't available.  For
    example, if some resource can't be used, such as the network
    appears to be unavailable, this should be raised instead of
    TestFailed.
    (   R   R   R   (    (    (    R   R      s   t   ResourceDeniedc           B   s   t  Z d  Z RS(   sà   Test skipped because it requested a disallowed resource.

    This is raised when a test calls requires() for a resource that
    has not be enabled.  It is used to distinguish between expected
    and unexpected skips.
    (   R   R   R   (    (    (    R   R      s   i   c         C   s
   |  a d  S(   N(   t   stdoutt   _original_stdout(   R   (    (    R   t   record_original_stdout'   s     c           C   s   t  p t i S(   N(   R	   t   sysR   (    (    (    R   t   get_original_stdout+   s    c         C   s(   y t  i |  =Wn t j
 o n Xd  S(   N(   R   t   modulest   namet   KeyError(   R   (    (    R   t   unload.   s    c         C   s³   t  |  ƒ d k } x™ t i D]Ž } y+ | i | i i | |  | i d ƒ ƒ Wn | i	 j
 o n Xy+ | i | i i | |  | i d ƒ ƒ Wq | i	 j
 o q Xq Wd S(   sm   "Forget" a module was ever imported by removing it from sys.modules and
    deleting any .pyc and .pyo files.Nt   pyct   pyo(
   R   t   modnamet   osR   t   patht   dirnamet   unlinkt   joint   extsept   error(   R   R   R   (    (    R   t   forget4   s     
	
 ++c         C   s   t  d j	 o
 |  t  j S(   sP   Test whether a resource is enabled.  Known resources are set by
    regrtest.py.N(   t   use_resourcest   Nonet   resource(   R   (    (    R   t   is_resource_enabledF   s     c         C   sf   t  i ƒ  i i i d ƒ d j o d Sn t |  ƒ p+ | d j o d |  } n t	 | ƒ ‚ n d S(   sÛ   Raise ResourceDenied if the specified resource is not available.

    If the caller's module is __main__ then automatically return True.  The
    possibility of False being returned occurs when regrtest.py is executing.R   t   __main__Ns$   Use of the `%s' resource not enabled(
   R   t	   _getframet   f_backt	   f_globalst   getR   R   t   msgR   R   (   R   R%   (    (    R   t   requiresK   s     "t    i1Ô  c         C   s    d k  } d k } x~ | d d d g D]j } y |  i | | f ƒ | SWq% | i j
 o7 \ } } | | i
 j o ‚  n t i d | IJq% Xq% Wt d ‚ d S(   s    Try to bind the sock to a port.  If we are running multiple
    tests and we don't try multiple ports, the test can fails.  This
    makes the test more robust.Ni³&  i(  iç€  s6     WARNING: failed to listen on port %d, trying anothers    unable to find port to listen on(   t   sockett   errnot   preferred_portt   portt   sockt   bindt   hostR   t   errR%   t
   EADDRINUSER   t
   __stderr__R   (   R,   R.   R*   R(   R/   R)   R%   R+   (    (    R   t	   bind_portY   s      f9.9999999999999995e-07c         C   sR  t  |  ƒ t  d ƒ j p t  | ƒ t  d ƒ j o` yR t |  | ƒ \ }  } t |  ƒ t | ƒ t } t |  | ƒ | j o d Sn WqEqEXn´ t  |  ƒ t  | ƒ j oš t  |  ƒ t  f  ƒ t  g  ƒ f j ou xU t t t	 |  ƒ t	 | ƒ ƒ ƒ D]2 } t |  | | | ƒ } | d j o | Sqò qò Wt t	 |  ƒ t	 | ƒ ƒ Sn t |  | ƒ S(   Nf0.0i    (   t   typet   xt   yt   coercet   abst   FUZZt   fuzzt   ranget   mint   lent   it   fcmpt   outcomet   cmp(   R4   R5   R=   R9   R?   (    (    R   R>   m   s     2>" i    t   javas   $testt   riscost   testfiles   @tests   @test-àòs   latin-1t   getwindowsversioni   i   s'   u"@test-\u5171\u6709\u3055\u308c\u308b"t   Latin1sg   WARNING: The filename %r CAN be encoded by the filesystem.  Unicode filename tests may not be effectives   w+s   /tmps6   WARNING: tests will fail, unable to write to: %s or %s(   s   unlinkc         C   s‹   d k  } | i i |  ƒ o |  Sn t i } | i i | ƒ g | } x> | D]6 } | i i | |  ƒ } | i i
 | ƒ o | SqM qM W|  S(   sÕ   Try to find a file on sys.path and the working directory.  If it is not
    found the argument passed to the function is returned (this does not
    necessarily signal failure; could still be the legitimate path).N(   R   R   t   isabst   fileR   R   t   heret   dnR   t   fnt   exists(   RG   RH   RI   R   R   RJ   (    (    R   t   findfileÌ   s     		  s   test failedc         C   s   |  p t | ƒ ‚ n d S(   s–   Verify that condition is true. If not, raise TestFailed.

       The optional argument reason can be given to provide
       a better error text.
    N(   t	   conditionR   t   reason(   RM   RN   (    (    R   t   verifyÚ   s     c         C   s(   |  | j p t d |  | f ‚ n d S(   s$  Raise TestFailed if a == b is false.

    This is better than verify(a == b) because, in case of failure, the
    error message incorporates repr(a) and repr(b) so you can see the
    inputs.

    Note that "not (a == b)" isn't necessarily the same as "a != b"; the
    former is tested.
    s   %r == %rN(   t   at   bR   (   RP   RQ   (    (    R   t   vereqä   s    	 c         C   sR   |  i ƒ  } | i ƒ  g  } | D] } | d | q! ~ } d i | ƒ } d | S(   s%   Like repr(dict), but in sorted order.s   %r: %rs   , s   {%s}N(   t   dictt   itemst   sortt   _[1]t   pairt	   reprpairsR   t
   withcommas(   RS   RX   RY   RT   RV   RW   (    (    R   t   sortdictò   s     
%c         C   s7   y t  |  d d ƒ Wn t j
 o n Xd |  GHd  S(   Ns   <string>t   execs   Missing SyntaxError: "%s"(   t   compilet	   statementt   SyntaxError(   R]   (    (    R   t   check_syntaxú   s
    t   BasicTestRunnerc           B   s   t  Z d „  Z RS(   Nc         C   s   t  i ƒ  } | | ƒ | S(   N(   t   unittestt
   TestResultt   resultt   test(   t   selfRd   Rc   (    (    R   t   run  s    
(   R   R   Rf   (    (    (    R   R`   
  s   c         C   s  t  o t i t i d d ƒ} n
 t ƒ  } | i |  ƒ } | i
 ƒ  pµ t | i ƒ d j o  | i o | i d d } np t | i ƒ d j o  | i o | i d d } n: | d j o
 d } n d | i | i f } t | ƒ ‚ t | ƒ ‚ n d S(   s2   Run tests from a unittest.TestSuite-derived class.t	   verbosityi   i   i    s0   errors occurred; run in verbose mode for detailss   errors occurred in %s.%sN(   t   verboseRa   t   TextTestRunnerR   R   t   runnerR`   Rf   t   suiteRc   t   wasSuccessfulR<   t   errorst   failuresR/   t	   testclassR   R%   R   R   R   (   Rk   Ro   R/   Rj   Rc   R%   (    (    R   t	   run_suite  s     	!!
c          G   s˜   t  i ƒ  } xQ |  D]I } t | t  i t  i f ƒ o | i | ƒ q | i t  i | ƒ ƒ q Wt	 |  ƒ d j o |  d } n d } t | | ƒ d S(   s1   Run tests from unittest.TestCase-derived classes.i   i    N(   Ra   t	   TestSuiteRk   t   classest   clst
   isinstancet   TestCaset   addTestt	   makeSuiteR<   Ro   R   Rp   (   Rr   Ro   Rk   Rs   (    (    R   t   run_unittest(  s      c         C   s¯   d k  } | d j o
 t } n d } t i } t ƒ  t _ z@ | i |  d | ƒ\ } } | o t d | | f ƒ ‚ n Wd | t _ Xt o d |  i | f GHn | | f S(   s  Run doctest on the given module.  Return (#failures, #tests).

    If optional argument verbosity is not specified (or is None), pass
    test_support's belief about verbosity on to doctest.  Else doctest's
    usual behavior is used (it searches sys.argv for -v).
    NRh   s   %d of %d doctests faileds,   doctest (%s) ... %d tests with zero failures(   t   doctestRg   R   Rh   R   R   t   save_stdoutR   t   testmodt   modulet   ft   tR   R   (   R|   Rg   Rz   R}   R~   Ry   (    (    R   t   run_doctest:  s      	
	 
(<   R   R   t   ImportErrorR   t	   ExceptionR    R   R   R   Rh   R   R   R	   R
   R   R   R   R   R&   R2   R8   R>   t   unicodet   have_unicodet	   NameErrort   platformt
   startswitht	   is_jythonR   R   t   TESTFNRt   t   TESTFN_UNICODEt   getfilesystemencodingt   TESTFN_ENCODINGt   hasattrRD   t   TESTFN_UNICODE_UNENCODEABLEt   evalt   encodet   UnicodeEncodeErrort   fpt   opent   IOErrorR   R   t
   TMP_TESTFNt   closeR   t   __file__RL   RO   RR   RZ   R_   Ra   R`   Rp   Rx   R   ($   RR   Rh   R`   Ra   R   R   R   R_   R‰   R   Rƒ   RO   R‡   R‹   R8   Rx   R   RL   R   R‘   R   R2   RZ   R   R    R   Rˆ   R
   R   R   R   R   R>   Rp   R”   R&   (    (    R   t   ?   s’   	
						
	


(


					