
bc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z x~ e j j   D]m Z e e d  r1g  e j D] Z e j j e  ^ qe _ n  e e d  r[e j j e j  e _ n  q We j d k ry d d l Z Wn e k
 rnN Xe j e j  \ Z Z  e! e  e" e d d   Z# e j$ e j e# e  f  n  e j d k ry d d l% Z% Wn e& k
 rn Xn  d	 Z' d
 Z( d Z) d Z* d Z+ d Z, d Z- d Z. d Z/ d Z0 d d l1 m2 Z2 d d d d d d d d d d d f Z3 e3 d f Z4 e j j e j5    a6 d d  Z7 d    Z8 i d! e' 6d" e( 6d# e) 6d$ e* 6d% e+ 6d& e, 6d' e- 6d( e. 6Z9 d)   Z: d*   Z; d+   Z< e= e= d
 e> e> e> e> e= e> e= e> d, e> e> e> e> e= e= e> e> e> e> e> e= d-  Z? d. d/ d0 d1 d2 d3 d4 d5 d6 g	 Z@ d7 d8 d9 h ZA e= e@ eA d:  ZB e> e= e> e> e= e= d;  ZC d< f  d=     YZD d>   ZE e> e> e= d?  ZF d@   ZG dA   ZH dB   ZI dC   ZJ dD   ZK e= dE  ZL dF   ZM dG   ZN dH dI e= dJ  ZO dK   ZP dL   ZQ dM   ZR i dN d 6dO dP 6dQ dR 6dQ dS 6dT dU 6dV dW 6dX d 6dY dZ 6d[ d\ 6d] d^ 6d_ d` 6da db 6dc dd 6de df 6dg dh 6di dj 6ZS eS dd eS dk <eS dd eS dl <eS dd eS dm <eS dd eS dn <do f  dp     YZT dq   ZU eV dr k re j j t  a t e j j e jW d
  k stX  eU   n  d S(s   s  
Usage:

python -m test.regrtest [options] [test_name1 [test_name2 ...]]
python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]


If no arguments or options are provided, finds all files matching
the pattern "test_*" in the Lib/test subdirectory and runs
them in alphabetical order (but see -M and -u, below, for exceptions).

For more rigorous testing, it is useful to use the following
command line:

python -E -tt -Wd -3 -m test.regrtest [options] [test_name1 ...]


Options:

-h/--help       -- print this text and exit

Verbosity

-v/--verbose    -- run tests in verbose mode with output to stdout
-w/--verbose2   -- re-run failed tests in verbose mode
-W/--verbose3   -- re-run failed tests in verbose mode immediately
-q/--quiet      -- no output unless one or more tests fail
-S/--slowest    -- print the slowest 10 tests
   --header     -- print header with interpreter info

Selecting tests

-r/--randomize  -- randomize test execution order (see below)
   --randseed   -- pass a random seed to reproduce a previous random run
-f/--fromfile   -- read names of tests to run from a file (see below)
-x/--exclude    -- arguments are tests to *exclude*
-s/--single     -- single step through a set of tests (see below)
-m/--match PAT  -- match test cases and methods with glob pattern PAT
--matchfile FILENAME -- filters tests using a text file, one pattern per line
-G/--failfast   -- fail as soon as a test fails (only with -v or -W)
-u/--use RES1,RES2,...
                -- specify which special resource intensive tests to run
-M/--memlimit LIMIT
                -- run very large memory-consuming tests

Special runs

-l/--findleaks  -- if GC is available detect tests that leak memory
-L/--runleaks   -- run the leaks(1) command just before exit
-R/--huntrleaks RUNCOUNTS
                -- search for reference leaks (needs debug build, v. slow)
-j/--multiprocess PROCESSES
                -- run PROCESSES processes at once
-T/--coverage   -- turn on code coverage tracing using the trace module
-D/--coverdir DIRECTORY
                -- Directory where coverage files are put
-N/--nocoverdir -- Put coverage files alongside modules
-t/--threshold THRESHOLD
                -- call gc.set_threshold(THRESHOLD)
-F/--forever    -- run the specified tests in a loop, until an error happens
-P/--pgo        -- enable Profile Guided Optimization training
--testdir       -- execute test files in the specified directory
                   (instead of the Python stdlib test suite)
--list-tests    -- only write the name of tests that will be run,
                   don't execute them
--list-cases    -- only write the name of test cases that will be run,
                   don't execute them
--fail-env-changed  -- if a test file alters the environment, mark the test
                       as failed


Additional Option Details:

-r randomizes test execution order. You can use --randseed=int to provide an
int seed value for the randomizer; this is useful for reproducing troublesome
test orders.

-s On the first invocation of regrtest using -s, the first test file found
or the first test file given on the command line is run, and the name of
the next test is recorded in a file named pynexttest.  If run from the
Python build directory, pynexttest is located in the 'build' subdirectory,
otherwise it is located in tempfile.gettempdir().  On subsequent runs,
the test in pynexttest is run, and the next test is written to pynexttest.
When the last test has been run, pynexttest is deleted.  In this way it
is possible to single step through the test files.  This is useful when
doing memory analysis on the Python interpreter, which process tends to
consume too many resources to run the full regression test non-stop.

-f reads the names of tests from the file given as f's argument, one
or more test names per line.  Whitespace is ignored.  Blank lines and
lines beginning with '#' are ignored.  This is especially useful for
whittling down failures involving interactions among tests.

-L causes the leaks(1) command to be run just before exit if it exists.
leaks(1) is available on Mac OS X and presumably on some other
FreeBSD-derived systems.

-R runs each test several times and examines sys.gettotalrefcount() to
see if the test appears to be leaking references.  The argument should
be of the form stab:run:fname where 'stab' is the number of times the
test is run to let gettotalrefcount settle down, 'run' is the number
of times further it is run and 'fname' is the name of the file the
reports are written to.  These parameters all have defaults (5, 4 and
"reflog.txt" respectively), and the minimal invocation is '-R :'.

-M runs tests that require an exorbitant amount of memory. These tests
typically try to ascertain containers keep working when containing more than
2 billion objects, which only works on 64-bit systems. There are also some
tests that try to exhaust the address space of the process, which only makes
sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit,
which is a string in the form of '2.5Gb', determines howmuch memory the
tests will limit themselves to (but they may go slightly over.) The number
shouldn't be more memory than the machine has (including swap memory). You
should also keep in mind that swap memory is generally much, much slower
than RAM, and setting memlimit to all available RAM or higher will heavily
tax the machine. On the other hand, it is no use running these tests with a
limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect
to use more than memlimit memory will be skipped. The big-memory tests
generally run very, very long.

-u is used to specify which special resource intensive tests to run,
such as those requiring large file support or network connectivity.
The argument is a comma-separated list of words indicating the
resources to test.  Currently only the following are defined:

    all -       Enable all special resources.

    audio -     Tests that use the audio device.  (There are known
                cases of broken audio drivers that can crash Python or
                even the Linux kernel.)

    curses -    Tests that use curses and will modify the terminal's
                state and output modes.

    largefile - It is okay to run some test that may create huge
                files.  These tests can take a long time and may
                consume >2GB of disk space temporarily.

    network -   It is okay to run tests that use external network
                resource, e.g. testing SSL support for sockets.

    bsddb -     It is okay to run the bsddb testsuite, which takes
                a long time to complete.

    decimal -   Test the decimal module against a large suite that
                verifies compliance with standards.

    cpu -       Used for certain CPU-heavy tests.

    subprocess  Run all tests for the subprocess module.

    urlfetch -  It is okay to download files required on testing.

    gui -       Run tests that require a running GUI.

    xpickle -   Test pickle and cPickle against Python 2.4, 2.5 and 2.6 to
                test backwards compatibility. These tests take a long time
                to run.

To enable all resources except one, use '-uall,-<resource>'.  For
example, to run all the tests except for the bsddb tests, give the
option '-uall,-bsddb'.

--matchfile filters tests using a text file, one pattern per line.
Pattern examples:

- test method: test_stat_attributes
- test class: FileTests
- test identifier: test_os.FileTests.test_stat_attributes
iNt   __path__t   __file__t   darwini   i   t   win32i   i    iiiiig      >@(   t   supportt   audiot   cursest	   largefilet   networkt   bsddbt   decimalt   cput
   subprocesst   urlfetcht   guit   xpicklet   extralargefilet    c         C   s$   t  GH| r | GHn  t j |   d  S(   N(   t   __doc__t   syst   exit(   t   codet   msg(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   usage  s     c         C   s   t  t j |  d   } t | d  \ }  } t |  d  \ } }  t | d  \ } } g  } | rx | j d |  n  | r | j d |  n  |  r | j d |   n  | r | j d |  n  | s d S| d	  } d
 j |  S(   Ng     @@i  i<   s   %s hours   %s mins   %s secs   %s mss   0 msi   t    (   t   intt   matht   ceilt   divmodt   appendt   join(   t   secondst   mst   minutest   hourst   parts(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   format_duration  s"    
s	   %s passeds	   %s faileds   %s failed (env changed)s
   %s skippeds   %s skipped (resource denied)s   %s interrupteds
   %s crasheds   %s run no testsc         C   s   t  j | d  } | |  S(   Ns   %s(   t   _FORMAT_TEST_RESULTt   get(   t	   test_namet   resultt   fmt(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   format_test_result4  s    c          C   s]   y t  j d  SWn t t f k
 r* n Xy d d  l }  Wn t k
 rN n X|  j   Sd  S(   Nt   SC_NPROCESSORS_ONLNi(   t   ost   sysconft   AttributeErrort
   ValueErrort   multiprocessingt   ImportErrort	   cpu_countt   None(   R0   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR2   9  s    
c         C   sI   xB t  j j   D]1 } | |  k r | j d  r t j |  q q Wd  S(   Ns   test.(   R   t   modulest   keyst
   startswithR   t   unload(   t   save_modulest   module(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   unload_test_modulesK  s    t   coveragec   [   &      s  t  j     t j t j  y t j t j d d d d d d d d d	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% g#  \ } } Wn# t j k
 r } t d& |  n X| dD k r t
 j d'  } n    dD k rg    n  dD } t } t } t  t } xD| D]<\ } }  | d k rNt d*  q)| d k rg! d 7! q)| d k r|t } q)| d k rt } q)| d k rt  q)| d k rt  d* ! q)| d k rt } q)| d k rt } q)| d k r t  q)| d k rt } q)| d> k r0t |   } q)| d k rE|  } q)| d k rv dD k rfg   n   j |   q)| dC k r dD k rg   n  t j j t j |   }! t |!  + }" x! |" D] }#  j |# j    qWWdD QXq)| d k r t } q)| d k rt } q)| d k rCdK dD l }$ |$ j t |    q)| d k rXt }
 q)| d k rt j j t j   |   } q)| d k rdD } q)| d k rc|  j dT   t   d k r|  G GHt d& dV  n   d* sdW  d* <n t  d*   d* < d sdX  d <n t  d   d <t   d& k sP d& redY g  d& )qeq)| d k rt j |   q)| d k rjg  |  j d^  D] }% |% j   ^ q}& x|& D] }' |' d_ k rt   (qn  t }( |' d* d` k rt }( |' d }' n  |' t k r"t d da |   n  |( rG|'   k rc  j |'  qcq|'   k r  j |'  qqWq)| d k rt } q)| d k rt |   } q)| df k rt } q)| dg k r|  } q)| d k rt  q)| dj k r|   q)| dk k rt } q)| dl k rt } q)| dm k r-t  q)| dn k rBt } q)t j  do j! |  IJt j" d  q)W| r| rt d& dp  n  | r|
 rt d& dq  n  | r| rt d& dr  n   r! p| rt ds  n   rt j j#    t j j$ d*   n  t j j# t j j% t&   }) x< dt |) f D]. }* y t j j |*  Wq6t' k
 rcq6Xq6W r \ }+ }, }- |+ d k  s|, d k  rdu } t j  | IJt j" d&  qn  | rfdK dD l( }. t j) t j  t j j t* dv  }* dw t* GHxX |. j( |*  D]G }/ t j j+ |/  r<dx |/ GHt j, |/  qdy |/ GHt j- |/  qWt j" d*  n  | dD k	 rt. j/ |  \ } }0  r |0 dz <n  y t0 | |0   }1 Wn% t1 k
 r}2 t2 |2 j3 j4 f }1 n XHt. j5 |1  GHt j" d*  n  g   g   g   g   g   g   g   dD 	 t  | rh	y dK dD l }$ Wn t6 k
 r^	d{ GHt } qh	Xg  }3 n  | r	t j j t* d|  }! y8 t |! d}  }" |" j7   j   }4 |4 g  |" j8   Wq	t9 k
 r	q	Xn  | rP
g   t t j j t j |   }" xD |" D]< }# |# j   }5 |5 r
|5 d* j: d~  r
 j; |5  q
q
W|" j8   n  t< |  t<   t= }6 t> j?   }7 | r
x7 | D]/ }8 |8 |6 k r
|6 j |8  n  |7 j@ |8  q
Wg  } n   r
d GH|7 j@ d  n  ! s | s  p
| p
 p
| o }9 tA  |6 |7  }:  p(| p(|:  | rw d   y |: |: jB  d*  d }; WqwtC k
 rsdD }; qwXn  | rx  D] }/ |/ GHqWt j" d*  n  | rtD     t j" d*  n  |
 rdK dD lE }
 |
 jF d t d t  }< n  g     t _G tH t jI  }=        f d    | rqtJ      f d  }> |>    dt  dU  n1 tK    d j! t     t   d        f d   }? |9 r8d GtL jM   Gd j t jN j    GHd GtL jL d t  Gd t jO GHd Gt j   GHtP   }@ |@ r8d G|@ GHq8n   rd \ }+ }, }- |+ dU k  rdd GHqdn  | rt
 jQ |  d G| GHt
 jR   n  | r5y dK d lS mT }A Wn# t6 k
 rd GHt j" d&  n XdK d lU mU }B mV }C dK d lW mX  mY   tZ j[ d   |B            ! f d   }D |D    t j\   }E t j] g |E dA d g   r} di g  n  d |A f         f d     Y}F g  t^ |  D] }G |F   ^ q}H d t |H  GHx |H D] }I |I j_   qWd   }J d* }K d }L t` ta tb  }M yx|K | k  ry  jc d |M  }N WnO |C k
 r|J |H  }O |O r! r!d d j |O  GHt j jd   q!q!n X|N \  }P }Q }1  dD k r|K d 7}K q!n    |1   sp|1 \ }R }S te  |R  }T |R tf t2 f k r-|S tb k r- r-|T d tg |S  7}T n  |J |H  }O |O r` r`|T d d j |O  7}T n  |? |L |T  n  |P r~|P GHn  t j jd   |Q r rt j  |Q IJn  t j  jd   |1 d* t2 k r|1 d d k sth  ti  n  |L d 7}L q!WWn! ti k
 rt   j8   n Xx|H D] }I |I j   qWnd GHdD }U xtj  d  D]\ }L   s }T |U rd |T |U f }T n  |? |L |T  n          ! f	 d   }V t  j    }W |
 rtk tl    }X |< jm d d tn   d |X |X d }1 n{ yW |V   }1 | rX|1 d* to k rX s6d  GHn  t0  t   dD  dz  n  Wn! ti k
 rst  Pn
   n Xt  j    |W }S te  |1 d*  }U |S tb k rd |U tg |S  f }U n |1 d* tp k rdD }U n  | r*|$ jq   |$ jr r*d Gt |$ jr  Gd GH|3 j; |$ jr  |$ jr 2q*n  ts |=  qPW   	    f d   
   
            f d   }Y |Y   | r r
   	 Hd GH  x  D]  d  GHt j jd   y4 t t _t t0  t   dD  d  dz  }R Wn ti k
 r$HPqX|R d* tp tu tv tw h k r j   qqW rtx t   d  Gd GHty   n  |Y   n  | r|; rt |! d   }" |" jz |; d  WdD QXqt j- |!  n  |
 r|< j{   }' |' j| d t d t d |  n  | r#t j} d t j~    n  Ht  j     }Z d tg |Z  GHd 
   GH ret j" d&  n   r{t j" d  n   r rt j" dU  n  t j" d*  dD S(   sl  Execute a test suite.

    This also parses command-line options and modifies its behavior
    accordingly.

    tests -- a list of strings containing test names (optional)
    testdir -- the directory in which to look for tests (optional)

    Users other than the Python test suite will certainly want to
    specify testdir; if it's omitted, the directory containing the
    Python test suite is searched for.

    If the tests argument is omitted, the tests listed on the
    command-line will be used.  If that's empty, too, then all *.py
    files beginning with test_ will be used.

    The other default arguments (verbose, quiet, exclude,
    single, randomize, findleaks, use_resources, trace, coverdir,
    print_slow, and random_seed) allow programmers calling main()
    directly to set the values that would normally be set by flags
    on the command line.
    i   s    hvqxsSrf:lu:t:TD:NLR:FwWM:j:PGm:t   helpt   verboset   verbose2t   verbose3t   quiett   excludet   singlet   slowt   slowestt	   randomizes	   fromfile=t	   findleakss   use=s
   threshold=t   traces	   coverdir=t
   nocoverdirt   runleakss   huntrleaks=s	   memlimit=s	   randseed=s   multiprocess=s
   slaveargs=t   forevert   headert   pgot   failfasts   match=s   testdir=s
   list-testss
   list-casesR;   s
   matchfile=s   fail-env-changedt   cleanupi   i s   -hs   --helpi    s   -vs	   --verboses   -ws
   --verbose2s   -Ws
   --verbose3s   -Gs
   --failfasts   -qs   --quiets   -xs	   --excludes   -ss   --singles   -Ss   --slows	   --slowests   -rs   --randomizes
   --randseeds   -fs
   --fromfiles   -ms   --matchs   --matchfileNs   -ls   --findleakss   -Ls
   --runleakss   -ts   --thresholdis   -Ts
   --coverages   -Ds
   --coverdirs   -Ns   --nocoverdirs   -Rs   --huntrleakst   :i   s)   -R takes 2 or 3 colon-separated argumentsi   i   s
   reflog.txts   -Ms
   --memlimits   -us   --uset   ,t   allt   -s   Invalid -u/--use option: s   -Fs	   --forevers   -js   --multiprocesss   --headers   --slaveargss   -Ps   --pgos	   --testdirs   --list-testss   --list-casess   --fail-env-changeds	   --cleanupsQ   No handler for option {}.  Please report this as a bug at http://bugs.python.org.s   -s and -f don't go together!s   -T and -j don't go together!s   -l and -j don't go together!s#   -G/--failfast needs either -v or -WR   sw   Invalid values for the --huntrleaks/-R parameters. The number of warmups and repetitions must be at least 1 each (1:1).s   test_python_*s   Cleanup %s directorys   Remove directory: %ss   Remove file: %st   testdirs%   No GC available, disabling findleaks.t
   pynexttestt   rt   #sE   Warning: bpo-31731: test_io hangs with --huntrleaks: exclude the testt   test_iot   countc            s  | \ } } | t  t f k r4  j | |  f  n  | t k rP  j |   n | t t  f k rr   j |   n | t k r  j |   n | t k r  j |   nd | t k r  j |    j |   n; | t k r  j |   n | t k rt	 d |   n  d  S(   Ns   invalid test result: %r(
   t   CHILD_ERRORt   INTERRUPTEDR   t   PASSEDt   FAILEDt   ENV_CHANGEDt   SKIPPEDt   RESOURCE_DENIEDt   TEST_DID_NOT_RUNR/   (   t   testR(   t   okt	   test_time(   t   badt   environment_changedt   goodt   resource_deniedst   run_no_testst   skippedt
   test_times(    s#   /usr/lib/python2.7/test/regrtest.pyt   accumulate_result  s$    c         3   sA   x: t  r< x- |  D]% } | V  r% d  S r  r d  Sq Wq Wd  S(   N(   t   True(   t   testsRa   (   Rd   Re   t   fail_env_changed(    s#   /usr/lib/python2.7/test/regrtest.pyt   test_forever  s    	s   /{}c            s   d j   |    } t    t   } | rM  rM d j  | |  } n  d j  |  } t t d  r t j   d } d j  | |  } n  t j    } t j d t |   } d | | f } d	 j  | |  } | GHt	 j
 j   d  S(
   Ns
   {1:{0}}{2}s   {}/{}s   [{}]t
   getloadavgi    s   load avg: {:.2f} {}R   s   %s %ss   {} {}(   t   formatt   lent   hasattrR,   Rp   t   timet   datetimet	   timedeltaR   R   t   stdoutt   flush(   t
   test_indexRa   t   linet   failst   load_avg_1minRc   (   Rd   Re   RL   t   regrtest_start_timet
   test_countt   test_count_width(    s#   /usr/lib/python2.7/test/regrtest.pyt   display_progress  s    s   ==R   s   ==  t   aliaseds	   %s-endians   == CPU count:sh   WARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives!s   Using random seed(   t   Threads+   Multiprocess option requires thread support(   t   Queuet   Empty(   t   Popent   PIPEs   \[\d+ refs\]$c          3   sV   xO  D]G }  |    f t  d  d  d   d  d   f } |  | f Vq Wd  S(   Nt
   huntrleakst   use_resourcesRM   t   match_testsRL   (   t   dict(   Ra   t
   args_tuple(   RM   R   R   RL   R@   Rm   R   R=   (    s#   /usr/lib/python2.7/test/regrtest.pyt   tests_and_args  s    s   test.regrtestt   MultiprocessThreadc              sD   e  Z d Z d Z         f d    Z  f d   Z RS(   c   
         s  y t    \ } } Wn t k
 r7  j d  t SX d t j |  g }  rm | j d  f  n  zg t j   |  _	 | |  _
  | d   d   d t d t j d k } | j   \ } } | j   } Wd  d  |  _
 X j d |  } | d	 k rF| j   j d
  \ } } }	 |	 s4 j d  t St j |	  }	 n t d | f }	  j | | j   | j   |	 f  t S(   Ns   --slaveargss	   --testdirRw   t   stderrt   universal_newlinest	   close_fdst   ntR   i    s   
s   Exit code %s(   NNNN(   NNNN(   t   nextt   StopIterationt   putR3   Rl   t   jsont   dumpst   extendRt   t
   start_timet   current_testR,   t   namet   communicatet   waitt   subt   stript
   rpartitiont   loadsRY   t   rstript   False(
   t   selfRa   R   t   argst   popenRw   R   t   retcodet   _R(   (   R   R   t   base_cmdt   debug_output_patt   outputt   pendingRS   (    s#   /usr/lib/python2.7/test/regrtest.pyt   runtest  s8    		
%c            sK   y# t  } x | s! |  j   } q WWn! t k
 rF   j d    n Xd  S(   N(   NNNN(   R   R   t   BaseExceptionR   R3   (   R   t   stop(   R   (    s#   /usr/lib/python2.7/test/regrtest.pyt   run$  s    	N(   t   __name__t
   __module__R3   R   R   R   R   (    (   R   R   R   R   R   R   RS   (    s#   /usr/lib/python2.7/test/regrtest.pyR     s   !(s.   Run tests in parallel using %s child processesc         S   so   g  } xb |  D]Z } | j  } | s( q n  t j   | j } | t k r | j d | t |  f  q q W| S(   Ns   %s (%s)(   R   Rt   R   t   PROGRESS_MIN_TIMER   R$   (   t   workerst   runningt   workerR   t   dt(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_running3  s    	$t   timeouts   running: %ss   , s    (%s)s    -- running: %st   KeyboardInterrupts   Run tests sequentiallys   %s -- %sc             s>   t      d   d  d  d  }     |   |  S(   NRM   R   RS   (   R   R3   (   R(   (	   Rk   RM   R   R   RL   R@   Ra   RS   R=   (    s#   /usr/lib/python2.7/test/regrtest.pyt   local_runtesty  s    	s   result = local_runtest()t   globalst   localsR(   s"   Re-running test %r in verbose modes   %s in %ss   Warning: test createds   uncollectable object(s).c             s   g  }    r |  j  d  nG  r8  r8 |  j  d  n+ t       f  sc |  j  d  n   ry |  j  d  n  |  s |  j  d  n  d j |   }   r d  |  f }  n  |  S(   Nt   FAILUREs   ENV CHANGEDs   NO TEST RUNRZ   t   SUCCESSs   , s
   %s then %s(   R   t   anyR   (   R(   (   Rd   Re   Rn   t   first_resultRf   t   interruptedRi   (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_tests_result  s    c             s  Hd    GH ro  ro Hd GHt    t    t     t    }  t t |   d  Gd GHt |   n   r  r  r H  r  r  r t   d k r d Gn  t t   d  Gd GHn   r j d t  Hd	 GHx*  d
  D] \ } } d | | f GHq Wn    rI rIHt t    d  Gd GHt    n   r rHd j t t   d   GHt   n   rN rN rNHt t   d  Gd GHt   t   } t j	 } | j
   r9t    | j   t  	  } | r)t t |  d  Gd G| d GHt |  qKd G| d GHqNd GHd G| d GHn   r~d GHd t t   d  GHt   n  
 rd GHd t t 
  d  GHt 
  n  d  S(   Ns   == Tests result: %s ==s(   Test suite interrupted by signal SIGINT.Ra   s   omitted:i   t   Alls   OK.t   reverses   10 slowest tests:i
   s   - %s: %.1fss   failed:s%   {} altered the execution environment:s   skipped:t   skips   unexpected onRO   s   Those skips are all expected ont   .s6   Ask someone to teach regrtest.py about which tests ares   expected to get skipped onR   s   %s:s   re-run tests   %s run no tests:(   t   setRX   Rr   t	   printlistt   sortRl   Rq   t   _ExpectedSkipsR   t   platformt   isvalidt   getexpected(   t   omittedRc   Ra   t   et   platt   surprise(   Rd   Re   R   Rf   R   RL   t
   print_slowR@   t   rerunRg   Rh   t   selectedRi   Rj   (    s#   /usr/lib/python2.7/test/regrtest.pyt   display_result  sf    *'
		 s'   Re-running failed tests in verbose modeR   Ra   s   failed again:t   ws   
t   show_missingt   summaryt   coverdirs   leaks %ds   Total duration: %ss   Tests result: %si   (   s   -hs   --help(   s   -vs	   --verbose(   s   -ws
   --verbose2(   s   -Ws
   --verbose3(   s   -Gs
   --failfast(   s   -qs   --quiet(   s   -xs	   --exclude(   s   -ss   --single(   s   -Ss   --slows	   --slowest(   s   -rs   --randomize(   s   -fs
   --fromfile(   s   -ms   --match(   s   -ls   --findleaks(   s   -Ls
   --runleaks(   s   -ts   --threshold(   s   -Ts
   --coverage(   s   -Ds
   --coverdir(   s   -Ns   --nocoverdir(   s   -Rs   --huntrleaks(   i   i   (   s   -Ms
   --memlimit(   s   -us   --use(   s   -Fs	   --forever(   s   -js   --multiprocess(   s   -Ps   --pgo(   Rt   R   t   record_original_stdoutR   Rw   t   getoptt   argvt   errorR   R3   t   randomt	   randrangeR   Rl   R   R   R,   t   pathR   t   SAVEDCWDt   openR   t   gct   set_thresholdt   getcwdt   splitRr   t   set_memlimitt   lowert   ALL_RESOURCESt   RESOURCE_NAMESt   removeR   Rq   R   t   abspatht   insertt   dirnameR   R/   t   globt   chdirt   TEMPDIRt   isdirt   rmtreet   unlinkR   R   R   R   RZ   t	   __class__R   R   R1   t   readt   closet   IOErrorR6   R   t   removepyt   STDTESTSt   NOTTESTSt   copyt   addt	   findtestst   indext
   IndexErrort
   list_casesRG   t   TraceR   R   R4   t   listt   iterR   t   python_implementationt   versiont	   byteorderR2   t   seedt   shufflet	   threadingR   R   R   R   R   R   t   ret   compilet   args_from_interpreter_flagst
   executablet   ranget   startt   maxt   PROGRESS_UPDATER   R&   Rx   R*   RY   R$   t   AssertionErrorR   t	   enumerateR   R   t   runctxR   R\   R[   t   collectt   garbageR:   R=   R]   R^   R_   RX   R   t   writet   resultst   write_resultst   systemt   getpid([   Rm   RS   R=   R@   RA   RB   RE   t   fromfileRF   R   RG   R   RI   R   R>   R   t   random_seedt   use_mpR?   RJ   RK   RL   RM   R   t   optsR   R   t	   slaveargst
   list_testst   list_cases_optt   cleanup_testst   ot   at   filenamet   fpRz   R   t   xt   uRU   R   t   regrtest_dirR   t   warmupt   repetitionsR   R   R   t   kwargsR(   R   t   found_garbaget	   next_testt   gutst   stdtestst   nottestst   argt   display_headert   alltestst   next_single_testt   tracerR8   Ro   R   t   ncpuR   R   R   R   t   opt_argsR   t   iR   R   R   t   finishedRy   t   get_timeoutt   itemR   Rw   R   Rb   Rc   t   textt   previous_testR   R   t   nsR   t   duration(    ("   R   R   Rk   Rd   R   R   Re   Rn   RM   R   R   Rf   R   R   R   R   R   RL   R   R@   R}   R   Rg   Rh   R   Ri   Ra   R~   R   Rj   RS   Rm   R   R=   s#   /usr/lib/python2.7/test/regrtest.pyt   mainR  sN   												 					

(													
		

	,
		!					$
	.5"	
	'		
	!6B			
t   test_grammart   test_opcodest	   test_dictt   test_builtint   test_exceptionst
   test_typest   test_unittestt   test_doctestt   test_doctest2t   test_supportt   test_future1t   test_future2c   	      C   s   t  |   }  t j |   } g  } t |  | B} x^ | D]V } t j j |  \ } } | d  d k r8 | d k r8 | | k r8 | j |  q8 q8 W| t |  S(   s-   Return a list of all applicable test modules.i   t   test_s   .py(   t   findtestdirR,   t   listdirR   R   t   splitextR   t   sorted(	   RS   R2  R3  t   namesRm   t   othersR   t   modnamet   ext(    (    s#   /usr/lib/python2.7/test/regrtest.pyR   P  s    (c	   	      C   s{   | t  _ | d k	 r! | t  _ n  zE t  j |  t t  _ | rL t t  _ n  t	 |  | | | | |  SWd t
 |  |  Xd S(   s  Run a single test.

    test -- the name of the test
    verbose -- if true, print more messages
    quiet -- if true, don't print 'skipped' messages (probably redundant)
    test_times -- a list of (time, test_name) pairs
    huntrleaks -- run multiple times to test for leaks; requires a debug
                  build; a triple corresponding to -R's three arguments
    pgo -- if true, do not print unnecessary info when running the test
           for Profile Guided Optimization build

    Returns one of the test result constants:
        CHILD_ERROR      Child process crashed
        INTERRUPTED      KeyboardInterrupt when run under -j
        RESOURCE_DENIED  test skipped because resource denied
        SKIPPED          test skipped for some other reason
        ENV_CHANGED      test failed because it changed the execution environment
        FAILED           test failed
        PASSED           test passed
        EMPTY_TEST_SUITE test ran no subtests.
    N(   R   R=   R3   R   t   set_match_testsR   t   environment_alteredRl   RM   t   runtest_innert   cleanup_test_droppings(	   Ra   R=   R@   R   R   RL   RM   R   RS   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR   \  s    		t   saved_test_environmentc        	   B   s   e  Z d  Z e Z d e e d  Z d# Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d    Z d!   Z d"   Z RS($   s  Save bits of the test environment and restore them at block exit.

        with saved_test_environment(testname, verbose, quiet):
            #stuff

    Unless quiet is True, a warning is printed to stderr if any of
    the saved items was changed by the test.  The attribute 'changed'
    is initially False, but is set to True if a change is detected.

    If verbose is more than 1, the before and after state of changed
    items is also printed.
    i    c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   testnameR=   R@   RL   (   R   R^  R=   R@   RL   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   __init__  s    			s   sys.argvt   cwds	   sys.stdins
   sys.stdouts
   sys.stderrs
   os.environs   sys.paths   asyncore.socket_mapt   filesc         C   s   t  t j  t j t j f S(   N(   t   idR   R   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_sys_argv  s    c         C   s   | d t  _ | d t  j (d  S(   Ni   i   (   R   R   (   R   t
   saved_argv(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_sys_argv  s    c         C   s
   t  j   S(   N(   R,   R   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_cwd  s    c         C   s   t  j |  d  S(   N(   R,   R   (   R   t	   saved_cwd(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_cwd  s    c         C   s   t  j S(   N(   R   Rw   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_sys_stdout  s    c         C   s   | t  _ d  S(   N(   R   Rw   (   R   t   saved_stdout(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_sys_stdout  s    c         C   s   t  j S(   N(   R   R   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_sys_stderr  s    c         C   s   | t  _ d  S(   N(   R   R   (   R   t   saved_stderr(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_sys_stderr  s    c         C   s   t  j S(   N(   R   t   stdin(   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_sys_stdin  s    c         C   s   | t  _ d  S(   N(   R   Ro  (   R   t   saved_stdin(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_sys_stdin  s    c         C   s"   t  t j  t j t t j  f S(   N(   Rb  R,   t   environR   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_os_environ  s    c         C   s2   | d t  _ t  j j   t  j j | d  d  S(   Ni   i   (   R,   Rs  t   cleart   update(   R   t   saved_environ(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_os_environ  s    c         C   s   t  t j  t j t j f S(   N(   Rb  R   R   (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_sys_path  s    c         C   s   | d t  _ | d t  j (d  S(   Ni   i   (   R   R   (   R   t
   saved_path(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_sys_path  s    c         C   s+   t  j j d  } | r' | j j   p* i  S(   Nt   asyncore(   R   R4   R&   t
   socket_mapR   (   R   R|  (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_asyncore_socket_map  s    c         C   sE   t  j j d  } | d  k	 rA | j d t  | j j |  n  d  S(   NR|  t
   ignore_all(   R   R4   R&   R3   t	   close_allRl   R}  Rv  (   R   t	   saved_mapR|  (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_asyncore_socket_map  s    c         C   sF   t  j j t j  r d } n$ t  j j t j  r< d } n d  } | S(   Nt   ft   d(   R,   R   t   isfileR   t   TESTFNR   R3   (   R   R(   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   get_support_TESTFN  s    		c         C   sc   | d  k r_ t j j t j  r4 t j t j  q_ t j j t j  r_ t j	 t j  q_ n  d  S(   N(
   R3   R,   R   R  R   R  R   R   t   shutilR   (   R   t   saved_value(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_support_TESTFN  s
    c         C   s    t  d   t j t j  D  S(   Nc         s   s1   |  ]' } | t  j j |  r$ d  n d Vq d S(   t   /R   N(   R,   R   R   (   t   .0t   fn(    (    s#   /usr/lib/python2.7/test/regrtest.pys	   <genexpr>  s   (   RT  R,   RR  t   curdir(   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt	   get_files  s    	c         C   sp   t  j } | | k rl | d | k rl t j j |  rG t  j |  ql t j j |  rl t  j |  ql n  d  S(   NR  (   R   R  R,   R   R  R   R   R   (   R   R  R  (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   restore_files  s    	c         c   s^   xW |  j  D]L } | j d d  } d | } d | } | t |  |  t |  |  f Vq
 Wd  S(   NR   R   t   get_t   restore_(   t	   resourcest   replacet   getattr(   R   R   t   method_suffixt   get_namet   restore_name(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   resource_info  s
    

c         C   s#   t  d   |  j   D  |  _ |  S(   Nc         s   s'   |  ] \ } } } | |   f Vq d  S(   N(    (   R  R   R&   t   restore(    (    s#   /usr/lib/python2.7/test/regrtest.pys	   <genexpr>  s    (   R   R  t   saved_values(   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyt	   __enter__  s    	c   
      C   s   |  j  } |  `  |  j t j O_ x |  j   D] \ } } } |   } | j |  }	 | |	 k r. t |  _ | |	  |  j r |  j r t	 j
 d j | |  j  IJt	 j
 d j |	 |  IJq q. q. Wt S(   Ns    Warning -- {} was modified by {}s     Before: {}
  After:  {} (   R  t   changedR   RZ  R  t   popRl   R@   RL   R   R   Rq   R^  R   (
   R   t   exc_typet   exc_valt   exc_tbR  R   R&   R  t   currentt   original(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   __exit__	  s"    			
(	   s   sys.argvR`  s	   sys.stdins
   sys.stdouts
   sys.stderrs
   os.environs   sys.paths   asyncore.socket_mapRa  (   R   R   R   R   R  R_  R  Rc  Re  Rf  Rh  Ri  Rk  Rl  Rn  Rp  Rr  Rt  Rx  Ry  R{  R~  R  R  R  R  R  R  R  R  (    (    (    s#   /usr/lib/python2.7/test/regrtest.pyR]    s:     																						c           C   s   t  j   d  S(   N(   R   t   reap_children(    (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   post_test_cleanup%  s    c      
   C   s  t  j |   | r d  } n t j   } d } t } yt j }	 z | rU | t _ n  t | |   }
 t   t	 |  | | |   } t
 j
   } t |
 t   t   g   } |
 j d  r t | |   } n | } t | d d   } | rt | |  | | |  } n | d  k	 r|   n  t
 j
   | } Wd  QXt   Wd  |	 t _ XWnt  j k
 r} | r| r|  Gd G| GHt j j   n  t | f St j k
 r} | r| r|  Gd G| GHt j j   n  t | f St k
 r  nt  j k
 r;} | s$t j d I|  Id I| IJn  t j j   t | f St  j k
 rUt | f St j   d  \ } } | st j d I|  Id It |  d	 I| IJn  t j j   | r| rt  j! d
 t j  t j j   n  t | f SX| rt | f S| j" rt# | f S| s| r't$ | f S| j%   } | sCt$ | f Sd G|  Gd GHd d GH| GHd d GHt j j   t | f Sd  S(   Ng        s   test.t	   test_mains
   skipped --Ra   s	   failed --i   s
   crashed --RO   t   files   produced unexpected output:t   *iF   (&   R   R7   R3   t   StringIOR   R   Rw   t   get_abs_modulet   clear_cachesR]  Rt   t
   __import__R   R   R6   R  t   dash_RR  t   ResourceDeniedRx   R_   t   unittestt   SkipTestR^   R   t
   TestFailedR   R\   t   TestDidNotRunR`   t   exc_infot   strt	   tracebackt	   print_excR  R]   R[   t   getvalue(   Ra   R=   R@   R   RL   RS   t   capture_stdoutRc   t   refleakt   save_stdoutt   abstestt   environmentR   t   the_packaget
   the_modulet   indirect_testR   t   typet   valueR   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR[  (  s    		


"

2
	


		c         C   sA  d d  l  } d d  l } | j   xt j d f D]} t j j |  sP q2 n  t j j |  ru d t	 j
 } } n5 t j j |  r d t j } } n t d |   | r d |  | | f GHn  yA t t d  r t j | | j | j B| j B n  | |  Wq2 t k
 r8} t j d |  | | | f IJq2 Xq2 Wd  S(	   Nit   db_homet	   directoryR  s8   os.path says %r exists but is neither directory nor files   %r left behind %s %rt   chmods3   %r left behind %s %r and it couldn't be removed: %s(   t   statR   R  R   R  R,   R   t   existsR   R  R   R  R   t   SystemErrorRs   R  t   S_IRWXUt   S_IRWXGt   S_IRWXOt	   ExceptionR   R   (   R^  R=   R  R   R   t   kindt   nukerR   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR\  {  s,    
	
$
c   )         s  d d l  } d d l } d d l } t t d  sB t d   n  t   t j } | j	 j
   }	 t j j
   }
 y d d l } Wn t k
 r d } n X| j j
   } i  } | | f } x g  | D]% } | j D] } t | |  ^ q q D]L } t | d  s
q n  x. | j   | g D] } | j j
   | | <qWq Wd   t d d  D   f d	   }   r  f d
   } n  f d   } g  } | \ } } } t j j t j |  } | | } d g | } d g | } t t |   } | s0t j d I| Id IJt j d | d d |  IJn  t | |	 |
 | |  d } } x | D] } |   | s}t j j d  n  t | |	 |
 | |  t j   }  t j   }! | |  |  | | <| |! |  | | <|  } |! } qWW| st j Jn  d   }" d   }# t  }$ x | d |" f | d |# f g D] \ } }% }& | | } |& |  r*d | | |% t! |  f }' t j |' IJt" | d   }( |( |' IJ|( j#   Wd QXt$ }$ q*q*W|$ S(   s   Run a test multiple times, looking for reference leaks.

    Returns:
        False if the test didn't leak references; True if we detected refleaks.
    iNt   gettotalrefcounts9   Tracking reference leaks requires a debug build of Pythont   _abc_registryc         S   s   i  |  ] } | |  q S(    (    (   R  R  (    (    s#   /usr/lib/python2.7/test/regrtest.pys
   <dictcomp>  s   	 ii  c            s     j  |  |   S(   N(   t
   setdefault(   R  (   t   int_pool(    s#   /usr/lib/python2.7/test/regrtest.pyt   get_pooled_int  s    c              s       d  S(   N(    (    (   R  (    s#   /usr/lib/python2.7/test/regrtest.pyt   run_the_test  s    c              s   t  j    d  S(   N(   t   impt   reload(    (   R  (    s#   /usr/lib/python2.7/test/regrtest.pyR    s    i    t	   beginningR-  t
   1234567890i
   i   R   c         S   s   t  d   |  D  S(   Nc         s   s   |  ] } | d  k Vq d S(   i   N(    (   R  t   delta(    (    s#   /usr/lib/python2.7/test/regrtest.pys	   <genexpr>  s    (   RQ   (   t   deltas(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   check_rc_deltas  s    c         S   s
   t  |   S(   N(   R   (   R  (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   check_fd_deltas
  s    t
   referencess   file descriptorss   %s leaked %s %s, sum=%sR&  (%   t   copy_regt   _abcollt   _pyioRs   R   R  t   warm_cachest   warningst   filterst   dispatch_tableR   t   path_importer_cachet	   zipimportR1   R3   t   _zip_directory_cachet   __all__R  t   __subclasses__R  R  R,   R   R   R   R   R  R   t   dash_R_cleanupR  R  t   fd_countR   t   sumR   Rx   Rl   ()   R  Ra   R  R   R@   R  R  R  t   fst   pst   picR  t   zdct   abcsR4   t   modR&  t   abct   objR  R  R  t   nwarmupt   ntrackedt   fnamet   repcountt	   rc_deltast	   fd_deltast	   rep_ranget	   rc_beforet	   fd_beforeR;  t   rc_aftert   fd_afterR  R  t   failedt	   item_namet   checkerR   t   refrep(    (   R  R  R  s#   /usr/lib/python2.7/test/regrtest.pyR    s    $

9
 


		

c   
      C   s   d d  l  } d d  l } |  t j (| j j   | j j |  t j j   t j j |  y d d  l	 } Wn t
 k
 r n X| j j   | j j |  t j   xC | j   D]5 \ } }	 |	 j   | _ | j j   | j j   q Wt   d  S(   Ni(   R   R  R  R  R  Ru  Rv  R   R  R  R1   R  t   _clear_type_cachet   itemsR   R  t
   _abc_cachet   _abc_negative_cacheR  (
   R  R  R  R  R  R   R  R  R  t   registry(    (    s#   /usr/lib/python2.7/test/regrtest.pyR    s$    

c          C   s  d d  l  }  x/ t j j   D] } t | d  r | ` q q Wy t j d } Wn t k
 rb n X| j j   t	 j
   y t j d } Wn t k
 r n X| j j   y t j d } Wn t k
 r n X| j   y t j d } Wn t k
 r n X| j   y t j d } Wn t k
 r.n X| j d   y t j d } Wn t k
 r`n X| j   y t j d	 } Wn t k
 rn X| j   y t j d
 }	 Wn t k
 rn X|	 j   y t j d }
 Wn t k
 rn X|
 j j   y t j d } Wn t k
 rn X| j   y t j d } Wn t k
 rNn
 Xd  | _ y t j d } Wn t k
 r|n X| j   t j   d  S(   Nit   __warningregistry__s   distutils.dir_utilt	   _strptimet   urlparset   urllibt   urllib2t   dircachet	   linecachet	   mimetypest   filecmpt   structt   doctestt   ctypes(   R   R   R4   t   valuesRs   R	  t   KeyErrort   _path_createdRu  R  t   purget   _regex_cachet   clear_cachet
   urlcleanupt   install_openerR3   t   resett
   clearcachet   _default_mime_typest   _cachet   _clearcachet   mastert   _reset_cacheR   t
   gc_collect(   R   R  t   distutils_dir_utilR
  R  R  R  R  R  R  R  R  R  R  (    (    s#   /usr/lib/python2.7/test/regrtest.pyR  8  s    






	
c          C   sY   x t  d  D] }  t |   q Wx t  d  D] }  t |   q. Wt t  d d   d S(   s}   Create explicitly internal singletons which are created on demand
    to prevent false positive when hunting reference leaks.i   ii  N(   R  t   chrt   unichrR  (   R;  (    (    s#   /usr/lib/python2.7/test/regrtest.pyR    s
    c         C   s   |  p t  j j t  p t  j S(   N(   R,   R   R   R   R  (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyRQ    s    c         C   s\   |  s
 d  SxK t  |   D]= \ } } t j j |  \ } } | d k r | |  | <q q Wd  S(   Ns   .py(   R  R,   R   RS  (   RU  t   idxR   t   basenameRX  (    (    s#   /usr/lib/python2.7/test/regrtest.pyR     s    c         C   s,   |  d k r d |  | f Sd |  | f Sd  S(   Ni   s   %d %ss   %d %ss(    (   t   nt   word(    (    s#   /usr/lib/python2.7/test/regrtest.pyRX     s    iF   i   c      	   C   sV   d d l  m } d | } | | d j d   t |   D  | d | d | IJd S(   s   Print the elements of iterable x to stdout.

    Optional arg width (default 70) is the maximum line length.
    Optional arg indent (default 4) is the number of blanks with which to
    begin each line.
    i(   t   fillR   c         s   s   |  ] } t  |  Vq d  S(   N(   R  (   R  t   elt(    (    s#   /usr/lib/python2.7/test/regrtest.pys	   <genexpr>  s    t   initial_indentt   subsequent_indentN(   t   textwrapR,  R   RT  (   R)  t   widtht   indentR  R,  t   blanks(    (    s#   /usr/lib/python2.7/test/regrtest.pyR     s    
)c         C   s%   | j  d  s |  r | Sd | Sd  S(   Ns   test.(   R6   (   RS   Ra   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR    s    c         C   sf   x_ |  D]W } t  | t j  r, t |  q t  | t j  r t j |  r^ | j   GHq^ q q Wd  S(   N(   t
   isinstanceR  t	   TestSuitet   _list_casest   TestCaseR   t
   match_testRb  (   t   suiteRa   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR6    s    c         C   s   t  t _ t j |  t t j  } g  } xk | D]c } t |  |  } y  t j	 j
 |  } t |  Wn! t j k
 r | j |  n Xt |  q2 W| r t j Jt j t t |  d  Id IJt | d t j n  d  S(   NRa   s   skipped:R  (   R   R   R=   RY  R   R   R4   R  R  t   defaultTestLoadert   loadTestsFromNameR6  R  R   R:   R   RX   Rr   R   (   RS   R   R   R8   Ri   Ra   R  R9  (    (    s#   /usr/lib/python2.7/test/regrtest.pyR    s     	"sl  
        test__locale
        test_bsddb185
        test_bsddb3
        test_commands
        test_crypt
        test_curses
        test_dbm
        test_dl
        test_fcntl
        test_fork1
        test_epoll
        test_gdbm
        test_grp
        test_ioctl
        test_largefile
        test_kqueue
        test_mhlib
        test_openpty
        test_ossaudiodev
        test_pipes
        test_poll
        test_posix
        test_pty
        test_pwd
        test_resource
        test_signal
        test_spwd
        test_threadsignals
        test_timing
        test_wait3
        test_wait4
        s   
        test_bsddb185
        test_curses
        test_dl
        test_largefile
        test_kqueue
        test_ossaudiodev
        t   linux2s   
        test_bsddb
        test_bsddb185
        test_dl
        test_epoll
        test_largefile
        test_kqueue
        test_minidom
        test_openpty
        test_pyexpat
        test_sax
        test_sundry
        t	   unixware7t	   openunix8s  
        test_asynchat
        test_bsddb
        test_bsddb185
        test_dl
        test_fork1
        test_epoll
        test_gettext
        test_largefile
        test_locale
        test_kqueue
        test_minidom
        test_openpty
        test_pyexpat
        test_queue
        test_sax
        test_sundry
        test_thread
        test_threaded_import
        test_threadedtempfile
        test_threading
        t   sco_sv3se  
        test_asynchat
        test_atexit
        test_bsddb
        test_bsddb185
        test_bsddb3
        test_commands
        test_crypt
        test_dbm
        test_dl
        test_fcntl
        test_fork1
        test_epoll
        test_gdbm
        test_grp
        test_largefile
        test_locale
        test_kqueue
        test_mmap
        test_openpty
        test_poll
        test_popen2
        test_pty
        test_pwd
        test_strop
        test_sundry
        test_thread
        test_threaded_import
        test_threadedtempfile
        test_threading
        test_timing
        t   riscoss  
        test__locale
        test_bsddb
        test_bsddb3
        test_curses
        test_epoll
        test_gdb
        test_gdbm
        test_largefile
        test_locale
        test_kqueue
        test_minidom
        test_ossaudiodev
        test_poll
        s   
        test_bsddb
        test_bsddb185
        test_curses
        test_dbm
        test_epoll
        test_kqueue
        test_gdbm
        test_gzip
        test_openpty
        test_zipfile
        test_zlib
        t   sunos5sC  
        test_bsddb
        test_bsddb185
        test_curses
        test_dl
        test_epoll
        test_gdbm
        test_gzip
        test_largefile
        test_locale
        test_kqueue
        test_minidom
        test_openpty
        test_pyexpat
        test_sax
        test_zipfile
        test_zlib
        s   hp-ux11s  
        test_bsddb185
        test_curses
        test_dl
        test_gdbm
        test_epoll
        test_largefile
        test_locale
        test_kqueue
        test_mhlib
        test_mmap
        test_poll
        test_popen2
        test_resource
        t   atheoss   
        test_bsddb185
        test_bsddb3
        test_curses
        test_dbm
        test_epoll
        test_ioctl
        test_kqueue
        test_largefile
        test_locale
        test_ossaudiodev
        test_socketserver
        t   cygwinsN  
        test_audioop
        test_bsddb185
        test_bsddb3
        test_commands
        test_curses
        test_dl
        test_epoll
        test_kqueue
        test_largefile
        test_mhlib
        test_mmap
        test_openpty
        test_ossaudiodev
        test_pty
        test_resource
        test_signal
        t   os2emxs^  
        test_bsddb
        test_bsddb3
        test_epoll
        test_gdbm
        test_locale
        test_ossaudiodev
        test_pep277
        test_pty
        test_socketserver
        test_tcl
        test_tk
        test_ttk_guionly
        test_ttk_textonly
        test_timeout
        test_urllibnet
        test_multiprocessing
        t   freebsd4sH  
        test_bsddb
        test_bsddb185
        test_bsddb3
        test_bz2
        test_dl
        test_epoll
        test_gdbm
        test_gzip
        test_kqueue
        test_ossaudiodev
        test_tcl
        test_tk
        test_ttk_guionly
        test_ttk_textonly
        test_zipimport
        test_zlib
        t   aix5sa  
        test_ascii_formatd
        test_bsddb
        test_bsddb3
        test_ctypes
        test_dl
        test_epoll
        test_gdbm
        test_locale
        test_normalization
        test_ossaudiodev
        test_pep277
        test_tcl
        test_tk
        test_ttk_guionly
        test_ttk_textonly
        test_multiprocessing
        t   openbsd3sp  
        test_ascii_formatd
        test_bsddb
        test_bsddb185
        test_bsddb3
        test_ctypes
        test_curses
        test_dl
        test_epoll
        test_gdbm
        test_locale
        test_ossaudiodev
        test_pep277
        test_tcl
        test_tk
        test_ttk_guionly
        test_ttk_textonly
        test_multiprocessing
        t   netbsd3t   freebsd5t   freebsd6t   freebsd7t   freebsd8R   c           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s0  d d  l  } d d l m } t |  _ t j t k r,t t j } t | j	    |  _
 |  j
 j d  | j j s |  j
 j d  n  | j r |  j
 j d  n  t j d k r |  j
 j d  n  t j d k rd	 d
 d d d d g } xO | D] } |  j
 j |  q Wn. t d j d   d k r<|  j
 j d
  n  t j d k rd d d d d d g } x! | D] } |  j
 j |  qjWn  t j d k rd d d d d d g } x! | D] } |  j
 j |  qWn  t j d k r|  j
 j d   |  j
 j d!  n  t j s |  j
 j d"  n  t |  _ n  d  S(#   Ni(   t   test_timeoutt   test_linuxaudiodevt   test_pep277RM  l    t   test_imageopR   t
   test_macost   test_macostoolst   test_aepackt   test_plistlibt   test_scriptpackagest   test_applesingleu    s   unicode-internali   R   t   test_unicode_filet   test_winregt   test_winsoundt   test_startfilet   test_sqlitet   test_msilibt   irixt   test_alt   test_cdt   test_clt   test_glt   test_imgfileRA  t   test_sunaudiodevt   test_nist   test_py3kwarn(   t   os.pathRa   RM  R   t   validR   R   t   _expectationsR   R   t   expectedR   R   t   supports_unicode_filenamest   skip_expectedt   maxintRr   t   encodet   py3kwarningRl   (   R   R,   RM  t   st   MAC_ONLYR   t   WIN_ONLYt	   IRIX_ONLY(    (    s#   /usr/lib/python2.7/test/regrtest.pyR_  .  sL    					c         C   s   |  j  S(   s@   Return true iff _ExpectedSkips knows about the current platform.(   Rg  (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR   e  s    c         C   s   |  j    s t  |  j S(   sn   Return set of test names we expect to skip on current platform.

        self.isvalid() must be true.
        (   R   R  Ri  (   R   (    (    s#   /usr/lib/python2.7/test/regrtest.pyR   i  s    (   R   R   R_  R   R   (    (    (    s#   /usr/lib/python2.7/test/regrtest.pyR   -  s   	7	c          C   s   t  j   ra t j j t  j d  d  a t j j t  a t j j t  sa t j	 t  qa n  d j
 t j    }  t j j t |   }  t j |  d t  t   Wd QXd S(   s,   Run main() in a temporary working directory.t   srcdirt   builds   test_python_{}R@   N(   t	   sysconfigt   is_python_buildR,   R   R   t   get_config_varR   R   R  t   mkdirRq   R  R   t   temp_cwdRl   RC  (   t   TESTCWD(    (    s#   /usr/lib/python2.7/test/regrtest.pyt   main_in_temp_cwdr  s    t   __main__(Y   R   R  Ru   R   R  R   R   R,   R   R   R  R  R   Ru  t   tempfileRt   R  R  R  R4   t
   itervaluesR9   Rs   R    R   R   R   t   resourceR1   t	   getrlimitt   RLIMIT_STACKt   softt   hardt   minR  t   newsoftt	   setrlimitt   FixTkR  R[   R\   R]   R^   R_   RZ   RY   R`   R   R  Ra   R   R   R   t
   gettempdirR   R   R$   R%   R*   R2   R:   R3   R   RC  R   R   R   R   R]  R  R[  R\  R  R  R  R  RQ  R   RX   R   R  R6  R  Rh  R   R{  R   R   R  (    (    (    s#   /usr/lib/python2.7/test/regrtest.pyt   <module>   s  .			
			  			/	S	'	z		c						#"	!
E	%