%PDF- %PDF-
Direktori : /usr/local/lib/python2.7/test/ |
Current File : //usr/local/lib/python2.7/test/test_tools.pyc |
ó Nêáac @ 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 m Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z e j ƒ rÇ e j d ƒ ‚ n e j j e j j e j j e j j e ƒ ƒ ƒ d ƒ Z e j j e d ƒ Z d e j f d „ ƒ YZ d e j f d „ ƒ YZ d e j f d „ ƒ YZ d e j f d „ ƒ YZ d „ Z e d k r›e j ƒ n d S( sº Tests for scripts in the Tools directory. This file contains regression tests for some of the scripts found in the Tools directory of a Python checkout or tarball, such as reindent.py. iÿÿÿÿN( t StringIO( t test_support( t assert_python_okt temp_dirs' test irrelevant for an installed Pythont Toolst scriptst ReindentTestsc B s/ e Z e j j e d ƒ Z d „ Z d „ Z RS( s reindent.pyc C s t | j ƒ d S( N( R t script( t self( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_noargs! s c C s? t | j d ƒ \ } } } | j | d ƒ | j | d ƒ d S( Ns -ht ( R R t assertEqualt assertGreater( R t rct outt err( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_help$ s ( t __name__t __module__t ost patht joint scriptsdirR R R ( ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyR s t PindentTestsc B s€ e Z e j j 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 RS( s pindent.pyc C sJ t | ƒ 8 } t | ƒ # } | j | j ƒ | j ƒ ƒ Wd QXWd QXd S( N( t openR t readlines( R t fn1t fn2t f1t f2( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt assertFileEqual- s c G s] t j t j | j f | d t j d t j d t ƒ} | j | ƒ \ } } | j | ƒ | S( Nt stdint stdoutt universal_newlines( t subprocesst Popent syst executableR t PIPEt Truet communicatet assertIsNone( R t sourcet argst procR R ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt pindent1 s c C s! d j d „ | j ƒ Dƒ ƒ d S( Ns c s s | ] } | j ƒ Vq d S( N( t lstrip( t .0t line( ( s+ /usr/local/lib/python2.7/test/test_tools.pys <genexpr>; s ( R t splitlines( R t data( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt lstriplines: s c C sð d | _ t ƒ Ø} t j j | d ƒ } t | j ƒ } | j ƒ } Wd QXt | d ƒ } | j | ƒ Wd QXt | j d | ƒ \ } } } | j | d ƒ | j | d ƒ | d } | j t j j | ƒ ƒ t | ƒ } | j | j ƒ | ƒ Wd QXt | ƒ } | j ƒ } Wd QXt | d d ƒ | j | j | d ƒ | ƒ | j | j | d ƒ | ƒ t | j d | ƒ \ } } } | j | d ƒ | j | d ƒ t | ƒ } | j | j ƒ | ƒ Wd QXt | ƒ } | j | j ƒ | ƒ Wd QX| j | ƒ } t | d ƒ } | j | ƒ Wd QXt | j d | ƒ \ } } } | j | d ƒ | j | d ƒ t | ƒ } | j | j ƒ | ƒ Wd QXt | ƒ } | j ƒ } Wd QXt | d d ƒ | j | j | d ƒ | ƒ Wd QXd S( Ns _test.pyt ws -dR t ~t execs -cs -r( t Nonet maxDiffR R R R R R t readt writeR R t assertTruet existst compileR- R3 ( R t directoryt data_patht ft closedR R R t backupt cleant brokent indented( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_selftest= sL c C sp | j | j | d ƒ | ƒ | j | j | d ƒ | ƒ | j | ƒ } | j | j | d d d d ƒ | ƒ d S( Ns -cs -ds -rs -es -st 4( R R- R3 ( R RC RA RD ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt pindent_testh s c C s2 t j d ƒ } t j d ƒ } | j | | ƒ d S( Ns: if a: pass if a: pass else: pass if a: pass elif: pass else: pass while a: break while a: break else: pass for i in a: break for i in a: break else: pass try: pass finally: pass try: pass except TypeError: pass except ValueError: pass else: pass try: pass except TypeError: pass except ValueError: pass finally: pass with a: pass class A: pass def f(): pass s` if a: pass # end if if a: pass else: pass # end if if a: pass elif: pass else: pass # end if while a: break # end while while a: break else: pass # end while for i in a: break # end for for i in a: break else: pass # end for try: pass finally: pass # end try try: pass except TypeError: pass except ValueError: pass else: pass # end try try: pass except TypeError: pass except ValueError: pass finally: pass # end try with a: pass # end with class A: pass # end class A def f(): pass # end def f ( t textwrapt dedentRH ( R RC RA ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_statementsn s ? L c C s2 t j d ƒ } t j d ƒ } | j | | ƒ d S( Ns÷ def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 else: print 'oops!' sJ def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 # end if else: print 'oops!' # end if # end def foobar ( RI RJ RH ( R RC RA ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_multilevelÿ s c C s t j d ƒ } t j d ƒ } | j | j | d ƒ | ƒ | j | j | d ƒ | ƒ | j | ƒ } | j | j | d d d d ƒ | ƒ t j d ƒ } t j d ƒ } | j | j | d ƒ | ƒ | j | j | d ƒ | ƒ | j | ƒ } | j | j | d ƒ | ƒ d S( Ns\ if a: if b: pass s if a: if b: pass # end if # end if s -cs -ds -rs -es -st 9sD if a: if b: pass so if a: if b: pass # end if # end if ( RI RJ R R- R3 ( R RC RA RD ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_preserve_indents s % c C sZ t j d ƒ } t j d ƒ } | j | j | d ƒ | ƒ | j | j | d ƒ | ƒ d S( Nsƒ class\ \ A: def \ f: pass s¸ class\ \ A: def \ f: pass # end def f # end class A s -cs -d( RI RJ R R- ( R RC RA ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_escaped_newline; s c C s2 t j d ƒ } t j d ƒ } | j | | ƒ d S( Ns4 if a: pass sI if a: pass # end if ( RI RJ RH ( R RC RA ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_empty_lineS s c C s2 t j d ƒ } t j d ƒ } | j | | ƒ d S( Ns# if a: pass s8 if a: pass # end if ( RI RJ RH ( R RC RA ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_onelinea s ( R R R R R R R R R- R3 RF RH RK RL RN RO RP RQ ( ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyR * s + ‘ " t FixcidTestsc B s5 e Z d „ Z d „ Z d „ Z d d d d „ Z RS( c C s] d } d } | j | | ƒ } d } d } | j | d j d | d | d | d | ƒ ƒ d S( Ns int xx = "xx\"xx"[xx]; s int xx = 'x\'xx' + xx; s int yy = "xx\"xx"[yy]; s int yy = 'x\'xx' + yy; s0 1 < {old1}> {new1}{new1}2 < {old2}> {new2}{new2}t old1t old2t new1t new2( t run_scriptt assertMultiLineEqualt format( R RS RT t outputRU RV ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_parse_stringsm s c C s2 | j d d d d d d ƒ } | j | d ƒ d S( Nt substfiles xx yy *aa bb R+ s -ct -t inputs4 /* xx altered */ int xx; /* aa unaltered */ int aa; sˆ 1 < /* xx altered */ > /* yy altered */ /* yy altered */ 2 < int xx; > int yy; int yy; /* aa unaltered */ 4 < int aa; > int bb; int bb; ( s -cR] ( RW RX ( R RZ ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_alter_comments~ s c C s t j t j ƒ | j t j t j ƒ t j j t j d ƒ } t | d ƒ } | j d ƒ Wd QXt t j j t j d ƒ d ƒ } | j d ƒ Wd QXt j j t d ƒ } t j ƒ } | j d t j f ƒ } Wd QX| j | d j | ƒ d | j ƒ ƒ d S( Ns file.cR4 s int xx; s file.pys xx = 'unaltered' s fixcid.pyR+ s {}: 1 < int xx; > int yy; s stderr: %s( R t mkdirR t TESTFNt addCleanupt rmtreeR R R R: R t captured_stderrRW RX RY t getvalue( R t c_filenamet fileR t stderrRZ ( ( s+ /usr/local/lib/python2.7/test/test_tools.pyt test_directoryš s $ R R] s xx yy c C s t j d } t | d ƒ } | j | ƒ Wd QX| j t j | ƒ d d | g t | ƒ } t j j t d ƒ } t j t d | ƒ | t j t d t | ƒ ƒ Z t j ƒ G } y t j | d d ƒWn&