
    ;e                    X   d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
  G d de
j                  Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          Z G d' d(e          Z G d) d*e          Z G d+ d,e          Z G d- d.e          Z G d/ d0e          Z  G d1 d2e          Z! G d3 d4          Z" G d5 d6ee"          Z# G d7 d8ee"          Z$ G d9 d:ee"          Z% G d; d<e          Z& G d= d>e          Z' G d? d@e          Z( G dA dBe          Z) G dC dDe          Z* G dE dFe          Z+ G dG dHe          Z, G dI dJe          Z- G dK dLe          Z. G dM dNe          Z/ G dO dPe          Z0 G dQ dRe          Z1 G dS dTe          Z2 G dU dVe          Z3 G dW dXe          Z4 G dY dZe          Z5 G d[ d\e          Z6 G d] d^e          Z7 G d_ d`e          Z8 G da dbe          Z9 G dc dde          Z: G de dfe          Z; G dg dhe          Z< G di dje          Z= G dk dle          Z> G dm dne          Z? G do dpe          Z@ G dq dre          ZA G ds dte          ZBdS )uz" Test suite for the fixer modules     N)chain)
itemgetter)pygram
fixer_util)supportc                   @    e Zd ZddZd ZddZddZd Zdd	Zd
 Z	dS )FixerTestCaseNlib2to3c                     || j         g}t          j        |||          | _        g | _        d| _        t          | j        j        | j        j                  D ]}| j        |_	        d S )Nz<string>)
fixerr   get_refactorerrefactor	fixer_logfilenamer   	pre_order
post_orderlog)selffix_list	fixer_pkgoptionsr   s        0/usr/lib/python3.11/lib2to3/tests/test_fixers.pysetUpzFixerTestCase.setUp   sr    
|H.y(GLL"4=2=35 5 	' 	'EEII	' 	'    c                     t          j        |          }t          j        |          }| j                            || j                  }|                     |t          |                     |S N)r   reformatr   refactor_stringr   assertEqualstr)r   beforeaftertrees       r   _checkzFixerTestCase._check   s\    !&)) ''},,VT]CCD		***r   Fc                     |                      ||          }|                     |j                   |s|                     | j        g            d S d S r   )r$   
assertTruewas_changedr   r   )r   r!   r"   ignore_warningsr#   s        r   checkzFixerTestCase.check#   sZ    {{65))())) 	1T^R00000	1 	1r   c                     |                      ||          }|                     |d                    | j                             |s|                     |j                   d S d S )N )r$   assertInjoinr   r&   r'   )r   r!   r"   message	unchangedr#   s         r   warnszFixerTestCase.warns)   sd    {{65))grwwt~66777 	.OOD,-----	. 	.r   c                 8    |                      |||d           d S )NTr/   r0   )r   r!   r.   s      r   warns_unchangedzFixerTestCase.warns_unchanged/   s"    

667d
;;;;;r   c                 p    |                      ||           |s|                     | j        g            d S d S r   )r$   r   r   )r   r!   r(   s      r   r/   zFixerTestCase.unchanged2   sF    FF### 	1T^R00000	1 	1r   c                    | j         g}|                    |           t          j        d|          }|                                \  }}d| j         z   }|r'|d         j        j                            |          rd S |r)|d         j        j                            |          r|sd S |                     dd	                    d ||z   D                       d|d           d S )	Nr
   fix_zFixer run order (, c                 &    g | ]}|j         j        S  )	__class__
__module__).0xs     r   
<listcomp>z3FixerTestCase.assert_runs_after.<locals>.<listcomp>D   s    GGGqAK2GGGr   z) is incorrect; z should be last.)
r   extendr   r   
get_fixersr<   r=   endswithfailr-   )r   namesfixesrprepostns          r   assert_runs_afterzFixerTestCase.assert_runs_after7   s   U"9e44llnndTZ 	DH&1::1== 	F 	3r7$/88;; 	D 	F			GGSXGGGHHHH!!!M 	N 	N 	N 	N 	Nr   )Nr
   N)F)
__name__r=   __qualname__r   r$   r)   r0   r4   r/   rK   r;   r   r   r	   r	      s        	' 	' 	' 	'  1 1 1 1. . . .< < <1 1 1 1
N N N N Nr   r	   c                   $    e Zd ZdZd Zd Zd ZdS )Test_nenec                 :    d}d}|                      ||           d S )Nzif x <> y:
            passzif x != y:
            passr)   r   bas      r   
test_basiczTest_ne.test_basicI   *    

1ar   c                 :    d}d}|                      ||           d S )Nzif x<>y:
            passzif x!=y:
            passrR   rS   s      r   test_no_spaceszTest_ne.test_no_spacesQ   rW   r   c                 :    d}d}|                      ||           d S )Nzif x<>y<>z:
            passzif x!=y!=z:
            passrR   rS   s      r   test_chainedzTest_ne.test_chainedY   rW   r   N)rL   r=   rM   r   rV   rY   r[   r;   r   r   rO   rO   F   sF        E        r   rO   c                   T    e 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S )Test_has_keyhas_keyc                 :    d}d}|                      ||           d S )Nz$x = d.has_key("x") or d.has_key("y")zx = "x" in d or "y" in drR   rS   s      r   test_1zTest_has_key.test_1d   s&    6*

1ar   c                 :    d}d}|                      ||           d S )Nzx = a.b.c.d.has_key("x") ** 3zx = ("x" in a.b.c.d) ** 3rR   rS   s      r   test_2zTest_has_key.test_2i   &    /+

1ar   c                 :    d}d}|                      ||           d S )Nz!x = a.b.has_key(1 + 2).__repr__()zx = (1 + 2 in a.b).__repr__()rR   rS   s      r   test_3zTest_has_key.test_3n   s&    3/

1ar   c                 :    d}d}|                      ||           d S )Nz,x = a.b.has_key(1 + 2).__repr__() ** -3 ** 4z(x = (1 + 2 in a.b).__repr__() ** -3 ** 4rR   rS   s      r   test_4zTest_has_key.test_4s   s&    >:

1ar   c                 :    d}d}|                      ||           d S )Nzx = a.has_key(f or g)zx = (f or g) in arR   rS   s      r   test_5zTest_has_key.test_5x   &    '#

1ar   c                 :    d}d}|                      ||           d S )Nzx = a + b.has_key(c)zx = a + (c in b)rR   rS   s      r   test_6zTest_has_key.test_6}   &    &"

1ar   c                 :    d}d}|                      ||           d S )Nzx = a.has_key(lambda: 12)zx = (lambda: 12) in arR   rS   s      r   test_7zTest_has_key.test_7   &    +'

1ar   c                 :    d}d}|                      ||           d S )Nzx = a.has_key(a for a in b)zx = (a for a in b) in arR   rS   s      r   test_8zTest_has_key.test_8   s&    -)

1ar   c                 :    d}d}|                      ||           d S )Nzif not a.has_key(b): passzif b not in a: passrR   rS   s      r   test_9zTest_has_key.test_9   s&    +%

1ar   c                 :    d}d}|                      ||           d S )Nz$if not a.has_key(b).__repr__(): passz if not (b in a).__repr__(): passrR   rS   s      r   test_10zTest_has_key.test_10   s&    62

1ar   c                 :    d}d}|                      ||           d S )Nzif not a.has_key(b) ** 2: passzif not (b in a) ** 2: passrR   rS   s      r   test_11zTest_has_key.test_11   s&    0,

1ar   N)rL   r=   rM   r   r`   rb   re   rg   ri   rl   ro   rr   rt   rv   rx   r;   r   r   r]   r]   a   s        E  
  
  
  
  
  
  
  
  
  
    r   r]   c                       e 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d Zd Zd Zd ZdS )
Test_applyapplyc                 :    d}d}|                      ||           d S )Nzx = apply(f, g + h)zx = f(*g + h)rR   rS   s      r   r`   zTest_apply.test_1   s&    %

1ar   c                 :    d}d}|                      ||           d S )Nzy = apply(f, g, h)zy = f(*g, **h)rR   rS   s      r   rb   zTest_apply.test_2   s&    $ 

1ar   c                 :    d}d}|                      ||           d S )Nz z = apply(fs[0], g or h, h or g)zz = fs[0](*g or h, **h or g)rR   rS   s      r   re   zTest_apply.test_3   &    2.

1ar   c                 :    d}d}|                      ||           d S )Nzapply(f, (x, y) + t)zf(*(x, y) + t)rR   rS   s      r   rg   zTest_apply.test_4   &    & 

1ar   c                 :    d}d}|                      ||           d S )Nzapply(f, args,)f(*args)rR   rS   s      r   ri   zTest_apply.test_5   s&    !

1ar   c                 :    d}d}|                      ||           d S )Nzapply(f, args, kwds,)f(*args, **kwds)rR   rS   s      r   rl   zTest_apply.test_6   s&    '"

1ar   c                 :    d}d}|                      ||           d S )Nzx = apply(f+g, args)zx = (f+g)(*args)rR   rS   s      r   test_complex_1zTest_apply.test_complex_1   rm   r   c                 :    d}d}|                      ||           d S )Nzx = apply(f*g, args)zx = (f*g)(*args)rR   rS   s      r   test_complex_2zTest_apply.test_complex_2   rm   r   c                 :    d}d}|                      ||           d S )Nzx = apply(f**g, args)zx = (f**g)(*args)rR   rS   s      r   test_complex_3zTest_apply.test_complex_3   rj   r   c                 :    d}d}|                      ||           d S )Nzx = apply(f.g, args)zx = f.g(*args)rR   rS   s      r   test_dotted_namezTest_apply.test_dotted_name   r   r   c                 :    d}d}|                      ||           d S )Nzx = apply(f[x], args)zx = f[x](*args)rR   rS   s      r   test_subscriptzTest_apply.test_subscript   s&    '!

1ar   c                 :    d}d}|                      ||           d S )Nzx = apply(f(), args)zx = f()(*args)rR   rS   s      r   	test_callzTest_apply.test_call   r   r   c                 :    d}d}|                      ||           d S )Nz"x = apply(a.b.c.d.e.f, args, kwds)zx = a.b.c.d.e.f(*args, **kwds)rR   rS   s      r   test_extremezTest_apply.test_extreme   s&    40

1ar   c                 :    d}d}|                      ||           d S )Nz1apply(   # foo
          f, # bar
          args)r   rR   rS   s      r   test_weird_commentszTest_apply.test_weird_comments   s*     

1ar   c                 4    d}|                      |           d S )Nzapply()r2   r   ss     r   test_unchanged_1zTest_apply.test_unchanged_1   s    qr   c                 4    d}|                      |           d S )Nzapply(f)r2   r   s     r   test_unchanged_2zTest_apply.test_unchanged_2   s    qr   c                 4    d}|                      |           d S )Nz	apply(f,)r2   r   s     r   test_unchanged_3zTest_apply.test_unchanged_3   s    qr   c                 4    d}|                      |           d S )Nzapply(f, args, kwds, extras)r2   r   s     r   test_unchanged_4zTest_apply.test_unchanged_4       .qr   c                 4    d}|                      |           d S )Nzapply(f, *args, **kwds)r2   r   s     r   test_unchanged_5zTest_apply.test_unchanged_5   s    )qr   c                 4    d}|                      |           d S )Nzapply(f, *args)r2   r   s     r   test_unchanged_6zTest_apply.test_unchanged_6      !qr   c                 4    d}|                      |           d S )Nzapply(f, **kwds)r2   r   s     r   test_unchanged_6bzTest_apply.test_unchanged_6b      "qr   c                 4    d}|                      |           d S )Nz#apply(func=f, args=args, kwds=kwds)r2   r   s     r   test_unchanged_7zTest_apply.test_unchanged_7
  s    5qr   c                 4    d}|                      |           d S )Nzapply(f, args=args, kwds=kwds)r2   r   s     r   test_unchanged_8zTest_apply.test_unchanged_8      0qr   c                 4    d}|                      |           d S )Nzapply(f, args, kwds=kwds)r2   r   s     r   test_unchanged_9zTest_apply.test_unchanged_9  s    +qr   c                 :    d}d}|                      ||           d S )Nzapply(  f,  args,   kwds)r   rR   r   rU   rT   s      r   test_space_1zTest_apply.test_space_1  &    +"

1ar   c                 :    d}d}|                      ||           d S )Nzapply(  f  ,args,kwds   )r   rR   r   s      r   test_space_2zTest_apply.test_space_2  r   r   N)rL   r=   rM   r   r`   rb   re   rg   ri   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r   r   rz   rz      s       E  
  
  
  
  
    
  
    
  
                            
    r   rz   c                   *    e Zd ZdZd Zd Zd Zd ZdS )Test_reloadreloadc                 :    d}d}|                      ||           d S )Nz	reload(a)z$import importlib
importlib.reload(a)rR   rS   s      r   testzTest_reload.test#  s&    7

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzreload( a ) # commentz0import importlib
importlib.reload( a ) # commentzreload( a )  # commentz1import importlib
importlib.reload( a )  # commentrR   rS   s      r   test_commentzTest_reload.test_comment(  sF    'C

1a )D

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzreload( a )z&import importlib
importlib.reload( a )z
reload( a)z%import importlib
importlib.reload( a)z
reload(a )z%import importlib
importlib.reload(a )rR   rS   s      r   
test_spacezTest_reload.test_space2  sb    9

1a8

1a8

1ar   c                    d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d	}|                      |           d S )
Nzreload(a=1)zreload(f, g)zreload(f, *h)zreload(f, *h, **i)zreload(f, **i)zreload(*h, **i)z
reload(*h)zreload(**i)zreload()r2   r   s     r   test_unchangedzTest_reload.test_unchanged?  s    qqq$q q!qqqqr   N)rL   r=   rM   r   r   r   r   r   r;   r   r   r   r      sU        E  
        r   r   c                   $    e Zd ZdZd Zd Zd ZdS )Test_interninternc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzx =   intern(  a  )z"import sys
x =   sys.intern(  a  )z%y = intern("b" # test
              )z4import sys
y = sys.intern("b" # test
              )zz = intern(a+b+c.d,   )z&import sys
z = sys.intern(a+b+c.d,   )rR   rS   s      r   test_prefix_preservationz$Test_intern.test_prefix_preservation^  sf    %5

1a

1a)9

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzx = intern(a)zimport sys
x = sys.intern(a)zz = intern(a+b+c.d,)z#import sys
z = sys.intern(a+b+c.d,)z"intern("y%s" % 5).replace("y", "")z1import sys
sys.intern("y%s" % 5).replace("y", "")rR   rS   s      r   r   zTest_intern.testm  sb    /

1a&6

1a4D

1ar   c                     d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzintern(a=1)zintern(f, g)z
intern(*h)zintern(**i)zintern()r2   r   s     r   r   zTest_intern.test_unchanged|  s{    qqqqqr   N)rL   r=   rM   r   r   r   r   r;   r   r   r   r   [  sF        E        r   r   c                   *    e Zd ZdZd Zd Zd Zd ZdS )Test_reducereducec                 :    d}d}|                      ||           d S )Nzreduce(a, b, c)z,from functools import reduce
reduce(a, b, c)rR   rS   s      r   test_simple_callzTest_reduce.test_simple_call  s&    ;

1ar   c                 :    d}d}|                      ||           d S )Nzdef x(arg): reduce(sum, [])z8from functools import reduce
def x(arg): reduce(sum, [])rR   rS   s      r   test_bug_7253zTest_reduce.test_bug_7253  s&    )G

1ar   c                 :    d}d}|                      ||           d S )Nzreduce(lambda x, y: x + y, seq)z<from functools import reduce
reduce(lambda x, y: x + y, seq)rR   rS   s      r   test_call_with_lambdaz!Test_reduce.test_call_with_lambda  s&    -K

1ar   c                     d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nz	reduce(a)zreduce(a, b=42)zreduce(a, b, c, d)zreduce(**c)zreduce()r2   r   s     r   r   zTest_reduce.test_unchanged  s{    qq qqqr   N)rL   r=   rM   r   r   r   r   r   r;   r   r   r   r     sU        E  
    
    r   r   c                   x    e 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S )
Test_printprintc                 :    d}d}|                      ||           d S )Nzprint 1,   1+1,   1+1+1zprint(1,   1+1,   1+1+1)rR   rS   s      r   r   z#Test_print.test_prefix_preservation  s&    )*

1ar   c                 b    d}|                      |           d}|                      |           d S )Nprint()	print('')r2   r   s     r   test_idempotencyzTest_print.test_idempotency  s6    qqr   c                     t           j        | j        j        _        d}|                     |           d}|                     |           d}|                     |           d S )Nprint(1, 1+1, 1+1+1)r   r   )r   !python_grammar_no_print_statementr   drivergrammarr/   r   s     r   "test_idempotency_print_as_functionz-Test_print.test_idempotency_print_as_function  s]    '-'O$&qqqr   c                 :    d}d}|                      ||           d S )Nzprint 1, 1+1, 1+1+1r   rR   rS   s      r   r`   zTest_print.test_1  s&    %&

1ar   c                 :    d}d}|                      ||           d S )Nz
print 1, 2zprint(1, 2)rR   rS   s      r   rb   zTest_print.test_2  s&    

1ar   c                 :    d}d}|                      ||           d S )Nr   r   rR   rS   s      r   re   zTest_print.test_3  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzprint whatever; printzprint(whatever); print()rR   rS   s      r   rg   zTest_print.test_4  s&    '*

1ar   c                 :    d}d}|                      ||           d S )Nzprint; print whatever;zprint(); print(whatever);rR   rS   s      r   ri   zTest_print.test_5  s&    (+

1ar   c                 :    d}d}|                      ||           d S )Nzprint (a, b, c)zprint((a, b, c))rR   rS   s      r   
test_tuplezTest_print.test_tuple  s&    !"

1ar   c                 :    d}d}|                      ||           d S )Nzprint 1, 2, 3,zprint(1, 2, 3, end=' ')rR   rS   s      r   test_trailing_comma_1z Test_print.test_trailing_comma_1  s&     )

1ar   c                 :    d}d}|                      ||           d S )Nzprint 1, 2,zprint(1, 2, end=' ')rR   rS   s      r   test_trailing_comma_2z Test_print.test_trailing_comma_2  s&    &

1ar   c                 :    d}d}|                      ||           d S )Nzprint 1,zprint(1, end=' ')rR   rS   s      r   test_trailing_comma_3z Test_print.test_trailing_comma_3  s&    #

1ar   c                 :    d}d}|                      ||           d S )Nzprint >>sys.stderr, 1, 2, 3zprint(1, 2, 3, file=sys.stderr)rR   rS   s      r   !test_vargs_without_trailing_commaz,Test_print.test_vargs_without_trailing_comma  s&    -1

1ar   c                 :    d}d}|                      ||           d S )Nzprint >>sys.stderr, 1, 2,z%print(1, 2, end=' ', file=sys.stderr)rR   rS   s      r   test_with_trailing_commaz#Test_print.test_with_trailing_comma   s&    +7

1ar   c                 :    d}d}|                      ||           d S )Nzprint >>sys.stderr, 1+1zprint(1+1, file=sys.stderr)rR   rS   s      r   test_no_trailing_commaz!Test_print.test_no_trailing_comma  s&    )-

1ar   c                 :    d}d}|                      ||           d S )Nzprint >>  sys.stderrzprint(file=sys.stderr)rR   rS   s      r   test_spaces_before_filez"Test_print.test_spaces_before_file
  s&    &(

1ar   c                 h    d}|                      |           d}d}|                     ||           d S )Nz<from __future__ import print_function
print('Hai!', end=' ')zprint 'Hello, world!'zprint('Hello, world!')r/   r)   )r   r   rT   rU   s       r   test_with_future_print_functionz*Test_print.test_with_future_print_function  s?    %q#$

1ar   N)rL   r=   rM   r   r   r   r   r`   rb   re   rg   ri   r   r   r   r   r   r   r   r   r   r;   r   r   r   r     s       E  
  	 	 	  
  
  
    
    
  
    
  
  
  
    r   r   c                   N    e 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S )	Test_execexecc                 :    d}d}|                      ||           d S )Nz  exec code in ns1,   ns2z  exec(code, ns1,   ns2)rR   rS   s      r   r   z"Test_exec.test_prefix_preservation  s&    +*

1ar   c                 :    d}d}|                      ||           d S )Nz	exec code
exec(code)rR   rS   s      r   rV   zTest_exec.test_basic!  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzexec code in nsexec(code, ns)rR   rS   s      r   test_with_globalszTest_exec.test_with_globals&  s&    ! 

1ar   c                 :    d}d}|                      ||           d S )Nzexec code in ns1, ns2exec(code, ns1, ns2)rR   rS   s      r   test_with_globals_localsz"Test_exec.test_with_globals_locals+  s&    '&

1ar   c                 :    d}d}|                      ||           d S )Nzexec (a.b()) in nszexec((a.b()), ns)rR   rS   s      r   r   zTest_exec.test_complex_10  &    $#

1ar   c                 :    d}d}|                      ||           d S )Nzexec a.b() + c in nszexec(a.b() + c, ns)rR   rS   s      r   r   zTest_exec.test_complex_25  &    &%

1ar   c                 4    d}|                      |           d S )Nr   r2   r   s     r   r   zTest_exec.test_unchanged_1<      qr   c                 4    d}|                      |           d S )Nzexec (code)r2   r   s     r   r   zTest_exec.test_unchanged_2@  s    qr   c                 4    d}|                      |           d S )Nr   r2   r   s     r   r   zTest_exec.test_unchanged_3D       qr   c                 4    d}|                      |           d S )Nr  r2   r   s     r   r   zTest_exec.test_unchanged_4H  s    &qr   N)rL   r=   rM   r   r   rV   r   r  r   r   r   r   r   r   r;   r   r   r   r     s        E  
  
  
  
  
            r   r   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
	Test_reprreprc                 :    d}d}|                      ||           d S )Nzx =   `1 + 2`zx =   repr(1 + 2)rR   rS   s      r   r   z"Test_repr.test_prefix_preservationO  &    #

1ar   c                 :    d}d}|                      ||           d S )Nzx = `1 + 2`zx = repr(1 + 2)rR   rS   s      r   test_simple_1zTest_repr.test_simple_1T  s&    !

1ar   c                 :    d}d}|                      ||           d S )Nzy = `x`zy = repr(x)rR   rS   s      r   test_simple_2zTest_repr.test_simple_2Y  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzz = `y`.__repr__()zz = repr(y).__repr__()rR   rS   s      r   test_complexzTest_repr.test_complex^  s&    $(

1ar   c                 :    d}d}|                      ||           d S )Nzx = `1, 2, 3`zx = repr((1, 2, 3))rR   rS   s      r   r   zTest_repr.test_tuplec  &    %

1ar   c                 :    d}d}|                      ||           d S )Nzx = `1 + `2``zx = repr(1 + repr(2))rR   rS   s      r   test_nestedzTest_repr.test_nestedh  s&    '

1ar   c                 :    d}d}|                      ||           d S )Nzx = `1, 2 + `3, 4``zx = repr((1, 2 + repr((3, 4))))rR   rS   s      r   test_nested_tupleszTest_repr.test_nested_tuplesm  s&    %1

1ar   N)rL   r=   rM   r   r   r  r  r  r   r  r  r;   r   r   r  r  L  s        E  
  
  
  
  
  
    r   r  c                   r    e 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S )Test_exceptexceptc                 :    d}d}|                      ||           d S )Nzq
            try:
                pass
            except (RuntimeError, ImportError),    e:
                passzs
            try:
                pass
            except (RuntimeError, ImportError) as    e:
                passrR   rS   s      r   r   z$Test_except.test_prefix_preservationu  ,    

 	

1ar   c                 :    d}d}|                      ||           d S )NzV
            try:
                pass
            except Foo, e:
                passX
            try:
                pass
            except Foo as e:
                passrR   rS   s      r   test_simplezTest_except.test_simple  r#  r   c                 :    d}d}|                      ||           d S )NzU
            try:
                pass
            except Foo,e:
                passr%  rR   rS   s      r   "test_simple_no_space_before_targetz.Test_except.test_simple_no_space_before_target  r#  r   c                 :    d}d}|                      ||           d S )Nz
            def foo():
                try:
                    pass
                except Exception, (f, e):
                    pass
                except ImportError, e:
                    passa  
            def foo():
                try:
                    pass
                except Exception as xxx_todo_changeme:
                    (f, e) = xxx_todo_changeme.args
                    pass
                except ImportError as e:
                    passrR   rS   s      r   test_tuple_unpackzTest_except.test_tuple_unpack  s,     	

1ar   c                 :    d}d}|                      ||           d S )Nzn
            try:
                pass
            except (RuntimeError, ImportError), e:
                passzp
            try:
                pass
            except (RuntimeError, ImportError) as e:
                passrR   rS   s      r   test_multi_classzTest_except.test_multi_class  s,    
 	

1ar   c                 :    d}d}|                      ||           d S )Nza
            try:
                pass
            except Exception, [a, b]:
                passz
            try:
                pass
            except Exception as xxx_todo_changeme:
                [a, b] = xxx_todo_changeme.args
                passrR   rS   s      r   test_list_unpackzTest_except.test_list_unpack  ,     	

1ar   c                 :    d}d}|                      ||           d S )Nz_
            try:
                pass
            except Exception, d[5]:
                passz
            try:
                pass
            except Exception as xxx_todo_changeme:
                d[5] = xxx_todo_changeme
                passrR   rS   s      r   test_weird_target_1zTest_except.test_weird_target_1  r/  r   c                 :    d}d}|                      ||           d S )Nz`
            try:
                pass
            except Exception, a.foo:
                passz
            try:
                pass
            except Exception as xxx_todo_changeme:
                a.foo = xxx_todo_changeme
                passrR   rS   s      r   test_weird_target_2zTest_except.test_weird_target_2  r/  r   c                 :    d}d}|                      ||           d S )Nzb
            try:
                pass
            except Exception, a().foo:
                passz
            try:
                pass
            except Exception as xxx_todo_changeme:
                a().foo = xxx_todo_changeme
                passrR   rS   s      r   test_weird_target_3zTest_except.test_weird_target_3  r/  r   c                 :    d}d}|                      ||           d S )Nz
            try:
                pass
            except Exception, a:
                pass
            except:
                passz
            try:
                pass
            except Exception as a:
                pass
            except:
                passrR   rS   s      r   test_bare_exceptzTest_except.test_bare_except  s,     	

1ar   c                 :    d}d}|                      ||           d S )Nz
            try:
                pass
            except Exception, a:
                pass
            except:
                pass
            else:
                pass
            finally:
                passz
            try:
                pass
            except Exception as a:
                pass
            except:
                pass
            else:
                pass
            finally:
                passrR   rS   s      r   !test_bare_except_and_else_finallyz-Test_except.test_bare_except_and_else_finally  s,    

 	

1ar   c                 :    d}d}|                      ||           d S )Nz
            try:
                pass
            except TypeError, b:
                pass
            except Exception, a:
                pass
            except:
                passz
            try:
                pass
            except TypeError as b:
                pass
            except Exception as a:
                pass
            except:
                passrR   rS   s      r   +test_multi_fixed_excepts_before_bare_exceptz7Test_except.test_multi_fixed_excepts_before_bare_except'  s,     	

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nzd
            try: raise TypeError
            except TypeError, e:
                pass
            zf
            try: raise TypeError
            except TypeError as e:
                pass
            zd
            try:
                raise TypeError
            except TypeError, e: pass
            zf
            try:
                raise TypeError
            except TypeError as e: pass
            zT
            try: raise TypeError
            except TypeError, e: pass
            zV
            try: raise TypeError
            except TypeError as e: pass
            z
            try: raise TypeError
            except TypeError, e: pass
            else: function()
            finally: done()
            z
            try: raise TypeError
            except TypeError as e: pass
            else: function()
            finally: done()
            rR   rS   s      r   test_one_line_suitesz Test_except.test_one_line_suites=  s    

 	

1a

 	

1a 	

1a 	

1ar   c                 4    d}|                      |           d S )NzO
            try:
                pass
            except:
                passr2   r   s     r   r   zTest_except.test_unchanged_1m  #    
 	qr   c                 4    d}|                      |           d S )NzY
            try:
                pass
            except Exception:
                passr2   r   s     r   r   zTest_except.test_unchanged_2u  r?  r   c                 4    d}|                      |           d S )Nzg
            try:
                pass
            except (Exception, SystemExit):
                passr2   r   s     r   r   zTest_except.test_unchanged_3}  r?  r   N)rL   r=   rM   r   r   r&  r(  r*  r,  r.  r1  r3  r5  r7  r9  r;  r=  r   r   r   r;   r   r   r   r   r  s
       E        *            $  4  ,, , ,`        r   r   c                   x    e 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S )
Test_raiseraisec                 :    d}d}|                      ||           d S )Nzraise Exception, 5raise Exception(5)rR   rS   s      r   rV   zTest_raise.test_basic  s&    $$

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzraise Exception,5rF  zraise   Exception,    5zraise   Exception(5)rR   rS   s      r   r   z#Test_raise.test_prefix_preservation  sD    #$

1a)&

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzraise Exception, 5 # foozraise Exception(5) # foozraise E, (5, 6) % (a, b) # foozraise E((5, 6) % (a, b)) # fooz:def foo():
                    raise Exception, 5, 6 # foozIdef foo():
                    raise Exception(5).with_traceback(6) # foorR   rS   s      r   test_with_commentszTest_raise.test_with_comments  sg    **

1a00

1a3B

1ar   c                 :    d}d}|                      ||           d S )Nzraise Exception(5), None, tbz%raise Exception(5).with_traceback(tb)rR   rS   s      r   test_None_valuezTest_raise.test_None_value  s&    .7

1ar   c                 :    d}d}|                      ||           d S )Nzraise Exception, (5, 6, 7)zraise Exception(5, 6, 7)rR   rS   s      r   test_tuple_valuezTest_raise.test_tuple_value  s&    ,*

1ar   c                 :    d}d}|                      ||           d S )Nzraise E, (5, 6) % (a, b)zraise E((5, 6) % (a, b))rR   rS   s      r   test_tuple_detectionzTest_raise.test_tuple_detection  s&    **

1ar   c                 :    d}d}|                      ||           d S )Nzraise (((E1, E2), E3), E4), Vraise E1(V)rR   rS   s      r   test_tuple_exc_1zTest_raise.test_tuple_exc_1  s&    /

1ar   c                 :    d}d}|                      ||           d S )Nzraise (E1, (E2, E3), E4), VrQ  rR   rS   s      r   test_tuple_exc_2zTest_raise.test_tuple_exc_2  s&    -

1ar   c                 6    d}|                      |d           d S )Nzraise 'foo'+Python 3 does not support string exceptionsr4   r   s     r   test_string_exczTest_raise.test_string_exc  s$    Q MNNNNNr   c                 6    d}|                      |d           d S )Nzraise "foo", 5rV  rW  r   s     r   test_string_exc_valzTest_raise.test_string_exc_val  $     Q MNNNNNr   c                 6    d}|                      |d           d S )Nzraise "foo", 5, 6rV  rW  r   s     r   test_string_exc_val_tbz!Test_raise.test_string_exc_val_tb  $    #Q MNNNNNr   c                 :    d}d}|                      ||           d S )Nz4def foo():
                    raise Exception, 5, 6Cdef foo():
                    raise Exception(5).with_traceback(6)rR   rS   s      r   	test_tb_1zTest_raise.test_tb_1  s*    -<

1ar   c                 :    d}d}|                      ||           d S )Nzhdef foo():
                    a = 5
                    raise Exception, 5, 6
                    b = 6wdef foo():
                    a = 5
                    raise Exception(5).with_traceback(6)
                    b = 6rR   rS   s      r   	test_tb_2zTest_raise.test_tb_2  ,     	

1ar   c                 :    d}d}|                      ||           d S )Nz2def foo():
                    raise Exception,5,6r`  rR   rS   s      r   	test_tb_3zTest_raise.test_tb_3  s*    +<

1ar   c                 :    d}d}|                      ||           d S )Nzfdef foo():
                    a = 5
                    raise Exception,5,6
                    b = 6rc  rR   rS   s      r   	test_tb_4zTest_raise.test_tb_4  re  r   c                 :    d}d}|                      ||           d S )Nz<def foo():
                    raise Exception, (5, 6, 7), 6zIdef foo():
                    raise Exception(5, 6, 7).with_traceback(6)rR   rS   s      r   	test_tb_5zTest_raise.test_tb_5  s+    5B

1ar   c                 :    d}d}|                      ||           d S )Nzpdef foo():
                    a = 5
                    raise Exception, (5, 6, 7), 6
                    b = 6z}def foo():
                    a = 5
                    raise Exception(5, 6, 7).with_traceback(6)
                    b = 6rR   rS   s      r   	test_tb_6zTest_raise.test_tb_6  re  r   N)rL   r=   rM   r   rV   r   rI  rK  rM  rO  rR  rT  rX  rZ  r]  ra  rd  rg  ri  rk  rm  r;   r   r   rC  rC    s!       E  
      
  
  
  
  O O OO O OO O O  	 	 	  	 	 	  	 	 	 	 	r   rC  c                   ~    e 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S )
Test_throwthrowc                 :    d}d}|                      ||           d S )Nzg.throw(Exception, 5)g.throw(Exception(5))rR   rS   s      r   r`   zTest_throw.test_1  s&    ''

1ar   c                 :    d}d}|                      ||           d S )Nzg.throw(Exception,5)rr  rR   rS   s      r   rb   zTest_throw.test_2  s&    &'

1ar   c                 :    d}d}|                      ||           d S )Nzg.throw(Exception, (5, 6, 7))zg.throw(Exception(5, 6, 7))rR   rS   s      r   re   zTest_throw.test_3  s&    /-

1ar   c                 :    d}d}|                      ||           d S )Nz5 + g.throw(Exception, 5)z5 + g.throw(Exception(5))rR   rS   s      r   rg   zTest_throw.test_4  s&    ++

1ar   c                 6    d}|                      |d           d S )Nzg.throw("foo")rV  rW  r   s     r   test_warn_1zTest_throw.test_warn_1  r[  r   c                 6    d}|                      |d           d S )Nzg.throw("foo", 5)rV  rW  r   s     r   test_warn_2zTest_throw.test_warn_2!  r^  r   c                 6    d}|                      |d           d S )Nzg.throw("foo", 5, 6)rV  rW  r   s     r   test_warn_3zTest_throw.test_warn_3%  s$    &Q MNNNNNr   c                 4    d}|                      |           d S )Nzg.throw(Exception)r2   r   s     r   test_untouched_1zTest_throw.test_untouched_1+      $qr   c                 4    d}|                      |           d S )Nzg.throw(Exception(5, 6))r2   r   s     r   test_untouched_2zTest_throw.test_untouched_2/  s    *qr   c                 4    d}|                      |           d S )Nz5 + g.throw(Exception(5, 6))r2   r   s     r   test_untouched_3zTest_throw.test_untouched_33  r   r   c                 :    d}d}|                      ||           d S )Nz7def foo():
                    g.throw(Exception, 5, 6)Fdef foo():
                    g.throw(Exception(5).with_traceback(6))rR   rS   s      r   ra  zTest_throw.test_tb_19  s*    0?

1ar   c                 :    d}d}|                      ||           d S )Nzkdef foo():
                    a = 5
                    g.throw(Exception, 5, 6)
                    b = 6zdef foo():
                    a = 5
                    g.throw(Exception(5).with_traceback(6))
                    b = 6rR   rS   s      r   rd  zTest_throw.test_tb_2@  re  r   c                 :    d}d}|                      ||           d S )Nz5def foo():
                    g.throw(Exception,5,6)r  rR   rS   s      r   rg  zTest_throw.test_tb_3K  s*    .?

1ar   c                 :    d}d}|                      ||           d S )Nzidef foo():
                    a = 5
                    g.throw(Exception,5,6)
                    b = 6r  rR   rS   s      r   ri  zTest_throw.test_tb_4R  re  r   c                 :    d}d}|                      ||           d S )Nz?def foo():
                    g.throw(Exception, (5, 6, 7), 6)zLdef foo():
                    g.throw(Exception(5, 6, 7).with_traceback(6))rR   rS   s      r   rk  zTest_throw.test_tb_5]  s+    8E

1ar   c                 :    d}d}|                      ||           d S )Nzsdef foo():
                    a = 5
                    g.throw(Exception, (5, 6, 7), 6)
                    b = 6zdef foo():
                    a = 5
                    g.throw(Exception(5, 6, 7).with_traceback(6))
                    b = 6rR   rS   s      r   rm  zTest_throw.test_tb_6d  re  r   c                 :    d}d}|                      ||           d S )Nz;def foo():
                    a + g.throw(Exception, 5, 6)zJdef foo():
                    a + g.throw(Exception(5).with_traceback(6))rR   rS   s      r   	test_tb_7zTest_throw.test_tb_7o  s+    4C

1ar   c                 :    d}d}|                      ||           d S )Nzodef foo():
                    a = 5
                    a + g.throw(Exception, 5, 6)
                    b = 6z~def foo():
                    a = 5
                    a + g.throw(Exception(5).with_traceback(6))
                    b = 6rR   rS   s      r   	test_tb_8zTest_throw.test_tb_8v  re  r   N)rL   r=   rM   r   r`   rb   re   rg   rw  ry  r{  r}  r  r  ra  rd  rg  ri  rk  rm  r  r  r;   r   r   ro  ro    s0       E  
  
  
  O O OO O OO O O        	 	 	  	 	 	  	 	 	  	 	 	 	 	r   ro  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )	Test_longlongc                 :    d}d}|                      ||           d S )Nzx = long(x)z
x = int(x)rR   rS   s      r   r`   zTest_long.test_1  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzy = isinstance(x, long)zy = isinstance(x, int)rR   rS   s      r   rb   zTest_long.test_2  &    )(

1ar   c                 :    d}d}|                      ||           d S )Nzz = type(x) in (int, long)zz = type(x) in (int, int)rR   rS   s      r   re   zTest_long.test_3  s&    ,+

1ar   c                 H   d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzlong = Truezs.long = Truezdef long(): passzclass long(): passzdef f(long): passzdef f(g, long): passzdef f(x, long=True): passr2   r   s     r   r   zTest_long.test_unchanged  s    qq"q$q#q&q+qr   c                 :    d}d}|                      ||           d S )Nzx =   long(  x  )zx =   int(  x  )rR   rS   s      r   r   z"Test_long.test_prefix_preservation  &    #"

1ar   N)	rL   r=   rM   r   r`   rb   re   r   r   r;   r   r   r  r    sd        E  
  
  
  ,    r   r  c                       e Zd ZdZd Zd ZdS )Test_execfileexecfilec                 >   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d S )Nzexecfile("fn")z4exec(compile(open("fn", "rb").read(), "fn", 'exec'))zexecfile("fn", glob)z:exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob)zexecfile("fn", glob, loc)z?exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob, loc)zexecfile("fn", globals=glob)zBexec(compile(open("fn", "rb").read(), "fn", 'exec'), globals=glob)zexecfile("fn", locals=loc)z@exec(compile(open("fn", "rb").read(), "fn", 'exec'), locals=loc)z(execfile("fn", globals=glob, locals=loc)zNexec(compile(open("fn", "rb").read(), "fn", 'exec'), globals=glob, locals=loc)rR   rS   s      r   test_conversionzTest_execfile.test_conversion  s     F

1a&L

1a+Q

1a.T

1a,R

1a:`

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzexecfile( "fn" )z6exec(compile(open( "fn", "rb" ).read(), "fn", 'exec'))zexecfile("fn",  globals = glob)zEexec(compile(open("fn", "rb").read(), "fn", 'exec'),  globals = glob)rR   rS   s      r   test_spacingzTest_execfile.test_spacing  sD    "H

1a1W

1ar   N)rL   r=   rM   r   r  r  r;   r   r   r  r    s7        E  2    r   r  c                   $    e Zd ZdZd Zd Zd ZdS )Test_isinstance
isinstancec                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nzisinstance(x, (int, int, int))zisinstance(x, int)z,isinstance(x, (int, float, int, int, float))zisinstance(x, (int, float))z1isinstance(x, (int, float, int, int, float, str))z isinstance(x, (int, float, str))z4isinstance(foo() + bar(), (x(), y(), x(), int, int))z/isinstance(foo() + bar(), (x(), y(), x(), int))rR   rS   s      r   test_remove_multiple_itemsz*Test_isinstance.test_remove_multiple_items  s    0$

1a>-

1aC2

1aFA

1ar   c                 :    d}d}|                      ||           d S )Nz4if    isinstance(  foo(), (  bar, bar, baz )) : passz/if    isinstance(  foo(), (  bar, baz )) : passrR   rS   s      r   r   z(Test_isinstance.test_prefix_preservation  s&    FA

1ar   c                 0    |                      d           d S )Nzisinstance(x, (str, int))r2   r   s    r   r   zTest_isinstance.test_unchanged  s    233333r   N)rL   r=   rM   r   r  r   r   r;   r   r   r  r    sF        E  "  
4 4 4 4 4r   r  c                       e 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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%S )&	Test_dictdictc                 >   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d S )Nzif   d. keys  (  )  : passz if   list(d. keys  (  ))  : passzif   d. items  (  )  : passz!if   list(d. items  (  ))  : passzif   d. iterkeys  ( )  : passzif   iter(d. keys  ( ))  : passz"[i for i in    d.  iterkeys(  )  ]z[i for i in    d.  keys(  )  ]zif   d. viewkeys  ( )  : passzif   d. keys  ( )  : passz"[i for i in    d.  viewkeys(  )  ]rR   rS   s      r   r   z"Test_dict.test_prefix_preservation  s    (.

1a)/

1a+-

1a0,

1a+'

1a0,

1ar   c                 >   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d}|                      ||           d S )
Nzd.keys() # foozlist(d.keys()) # foozd.items()  # foozlist(d.items())  # foozd.iterkeys()  # fooziter(d.keys())  # fooz/[i for i in d.iterkeys() # foo
               ]z+[i for i in d.keys() # foo
               ]zd.viewitems()  # foorR   rS   s      r   test_trailing_commentzTest_dict.test_trailing_comment  s    "

1a$

1a!#

1a

1a

1a"

1ar   c                     t           j        D ]P}d|z  }|                     |           d|z  }|                     |           d|z  }|                     |           Qd S )Nzs = %s(d.keys())zs = %s(d.values())zs = %s(d.items())r   consuming_callsr/   )r   wrapperr   s      r   r   zTest_dict.test_unchanged*  su    !1 	 	G"W,ANN1$w.ANN1#g-ANN1	 	r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nd.keys()list(d.keys())za[0].foo().keys()zlist(a[0].foo().keys())rR   rS   s      r   test_01zTest_dict.test_015  sD    

1a%

1ar   c                 :    d}d}|                      ||           d S )N	d.items()zlist(d.items())rR   rS   s      r   test_02zTest_dict.test_02>  s&    

1ar   c                 :    d}d}|                      ||           d S )N
d.values()zlist(d.values())rR   rS   s      r   test_03zTest_dict.test_03C  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzd.iterkeys()iter(d.keys())rR   rS   s      r   test_04zTest_dict.test_04H  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzd.iteritems()ziter(d.items())rR   rS   s      r   test_05zTest_dict.test_05M  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzd.itervalues()ziter(d.values())rR   rS   s      r   test_06zTest_dict.test_06R  s&    

1ar   c                 4    d}|                      |           d S )Nr  r2   r   s     r   test_07zTest_dict.test_07W  r	  r   c                 4    d}|                      |           d S )Nsorted(d.keys())r2   r   s     r   test_08zTest_dict.test_08[  s    qr   c                 :    d}d}|                      ||           d S )Nr  ziter(list(d.keys()))rR   rS   s      r   test_09zTest_dict.test_09_  s&    "

1ar   c                 :    d}d}|                      ||           d S )Nzfoo(d.keys())zfoo(list(d.keys()))rR   rS   s      r   rv   zTest_dict.test_10d  s&    !

1ar   c                 :    d}d}|                      ||           d S )Nfor i in d.keys(): print iz for i in list(d.keys()): print irR   rS   s      r   rx   zTest_dict.test_11i  s&    (.

1ar   c                 :    d}d}|                      ||           d S )Nzfor i in d.iterkeys(): print ir  rR   rS   s      r   test_12zTest_dict.test_12n  s&    ,(

1ar   c                 :    d}d}|                      ||           d S )N[i for i in d.keys()]z[i for i in list(d.keys())]rR   rS   s      r   test_13zTest_dict.test_13s  &    #)

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i in d.iterkeys()]r  rR   rS   s      r   test_14zTest_dict.test_14x  rj   r   c                 :    d}d}|                      ||           d S )N(i for i in d.keys())z(i for i in list(d.keys()))rR   rS   s      r   test_15zTest_dict.test_15}  r  r   c                 :    d}d}|                      ||           d S )Nz(i for i in d.iterkeys())r  rR   rS   s      r   test_16zTest_dict.test_16  rj   r   c                 :    d}d}|                      ||           d S )Nziter(d.iterkeys())r  rR   rS   s      r   test_17zTest_dict.test_17  &     

1ar   c                 :    d}d}|                      ||           d S )Nzlist(d.iterkeys())r  rR   rS   s      r   test_18zTest_dict.test_18  r  r   c                 :    d}d}|                      ||           d S )Nzsorted(d.iterkeys())r  rR   rS   s      r   test_19zTest_dict.test_19  &    "

1ar   c                 :    d}d}|                      ||           d S )Nzfoo(d.iterkeys())zfoo(iter(d.keys()))rR   rS   s      r   test_20zTest_dict.test_20  s&    !

1ar   c                 :    d}d}|                      ||           d S )Nzprint h.iterkeys().next()zprint iter(h.keys()).next()rR   rS   s      r   test_21zTest_dict.test_21  s&    ')

1ar   c                 :    d}d}|                      ||           d S )Nzprint h.keys()[0]zprint list(h.keys())[0]rR   rS   s      r   test_22zTest_dict.test_22  r  r   c                 :    d}d}|                      ||           d S )Nzprint list(h.iterkeys().next())z!print list(iter(h.keys()).next())rR   rS   s      r   test_23zTest_dict.test_23  s&    -/

1ar   c                 :    d}d}|                      ||           d S )Nzfor x in h.keys()[0]: print xz#for x in list(h.keys())[0]: print xrR   rS   s      r   test_24zTest_dict.test_24  s&    +1

1ar   c                 :    d}d}|                      ||           d S )Nzd.viewkeys()r  rR   rS   s      r   test_25zTest_dict.test_25  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzd.viewitems()r  rR   rS   s      r   test_26zTest_dict.test_26  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzd.viewvalues()r  rR   rS   s      r   test_27zTest_dict.test_27  s&    

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i in d.viewkeys()]r  rR   rS   s      r   test_28zTest_dict.test_28  rj   r   c                 :    d}d}|                      ||           d S )Nz(i for i in d.viewkeys())r  rR   rS   s      r   test_29zTest_dict.test_29  rj   r   c                 :    d}d}|                      ||           d S )Nziter(d.viewkeys())r  rR   rS   s      r   test_30zTest_dict.test_30  r  r   c                 :    d}d}|                      ||           d S )Nzlist(d.viewkeys())r  rR   rS   s      r   test_31zTest_dict.test_31  r  r   c                 :    d}d}|                      ||           d S )Nzsorted(d.viewkeys())r  rR   rS   s      r   test_32zTest_dict.test_32  r  r   N)'rL   r=   rM   r   r   r  r   r  r  r  r  r  r  r  r  r  rv   rx   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r;   r   r   r  r    s&       E  2  :	 	 	    
  
  
  
  
      
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
    r   r  c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )Test_xrangexrangec                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzx =    xrange(  10  )zx =    range(  10  )zx = xrange(  1  ,  10   )zx = range(  1  ,  10   )zx = xrange(  0  ,  10 ,  2 )zx = range(  0  ,  10 ,  2 )rR   rS   s      r   r   z$Test_xrange.test_prefix_preservation  sb    '&

1a+*

1a.-

1ar   c                 :    d}d}|                      ||           d S )Nzx = xrange(10)zx = range(10)rR   rS   s      r   test_single_argzTest_xrange.test_single_arg  &     

1ar   c                 :    d}d}|                      ||           d S )Nzx = xrange(1, 10)zx = range(1, 10)rR   rS   s      r   test_two_argszTest_xrange.test_two_args  r  r   c                 :    d}d}|                      ||           d S )Nzx = xrange(0, 10, 2)zx = range(0, 10, 2)rR   rS   s      r   test_three_argszTest_xrange.test_three_args  r  r   c                 
   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d S )Nzx = range(10, 3, 9)zx = list(range(10, 3, 9))zx = foo(range(10, 3, 9))zx = foo(list(range(10, 3, 9)))zx = range(10, 3, 9) + [4]zx = list(range(10, 3, 9)) + [4]zx = range(10)[::-1]zx = list(range(10))[::-1]zx = range(10)  [3]zx = list(range(10))  [3]rR   rS   s      r   test_wrap_in_listzTest_xrange.test_wrap_in_list  s    %+

1a*0

1a+1

1a%+

1a$*

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzfor i in xrange(10):
    j=izfor i in range(10):
    j=iz[i for i in xrange(10)][i for i in range(10)]rR   rS   s      r   test_xrange_in_forzTest_xrange.test_xrange_in_for  sD    /.

1a)(

1ar   c                 Z    |                      d           |                      d           d S )Nzfor i in range(10): passr
  r2   r  s    r   test_range_in_forzTest_xrange.test_range_in_for  s.    1222/00000r   c                 0    |                      d           d S )Nzx in range(10, 3, 9)r2   r  s    r   test_in_contains_testz!Test_xrange.test_in_contains_test  s    -.....r   c                 T    t           j        D ]}|                     d|z             d S )Nza = %s(range(10))r  )r   calls     r   test_in_consuming_contextz%Test_xrange.test_in_consuming_context  s9    . 	7 	7DNN.56666	7 	7r   N)rL   r=   rM   r   r   r  r  r  r  r  r  r  r  r;   r   r   r  r    s        E    
  
  
  *  1 1 1/ / /7 7 7 7 7r   r  c                   $     e Zd Z fdZd Z xZS )Test_xrange_with_reducec                 \    t          t          |                               ddg           d S )Nr  r   )superr  r   )r   r<   s    r   r   zTest_xrange_with_reduce.setUp!  s-    %t,,22Hh3GHHHHHr   c                 :    d}d}|                      ||           d S )Nzreduce(x, xrange(5))z0from functools import reduce
reduce(x, range(5))rR   rS   s      r   test_double_transformz-Test_xrange_with_reduce.test_double_transform$  s(    &

1ar   )rL   r=   rM   r   r  __classcell__r<   s   @r   r  r    sL        I I I I I      r   r  c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )Test_raw_input	raw_inputc                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzx =    raw_input(   )zx =    input(   )zx = raw_input(   ''   )x = input(   ''   )rR   rS   s      r   r   z'Test_raw_input.test_prefix_preservation-  sD    '#

1a)%

1ar   c                 :    d}d}|                      ||           d S )Nzx = raw_input()x = input()rR   rS   s      r   r`   zTest_raw_input.test_16  s&    !

1ar   c                 :    d}d}|                      ||           d S )Nzx = raw_input('')x = input('')rR   rS   s      r   rb   zTest_raw_input.test_2;  s&    #

1ar   c                 :    d}d}|                      ||           d S )Nzx = raw_input('prompt')x = input('prompt')rR   rS   s      r   re   zTest_raw_input.test_3@  s&    )%

1ar   c                 :    d}d}|                      ||           d S )Nzx = raw_input(foo(a) + 6)zx = input(foo(a) + 6)rR   rS   s      r   rg   zTest_raw_input.test_4E  rp   r   c                 :    d}d}|                      ||           d S )Nzx = raw_input(invite).split()zx = input(invite).split()rR   rS   s      r   ri   zTest_raw_input.test_5J  rc   r   c                 :    d}d}|                      ||           d S )Nz x = raw_input(invite) . split ()zx = input(invite) . split ()rR   rS   s      r   rl   zTest_raw_input.test_6O  r   r   c                 :    d}d}|                      ||           d S )Nzx = int(raw_input())zx = int(input())rR   rS   s      r   rr   zTest_raw_input.test_8T  r  r   N)rL   r=   rM   r   r   r`   rb   re   rg   ri   rl   rr   r;   r   r   r  r  *  s        E    
  
  
  
  
  
    r   r  c                   &    e Zd ZdZg dZd Zd ZdS )Test_funcattrs	funcattrs)closuredocnamedefaultscodeglobalsr  c                     | j         D ]B}d|z  }d|z  }|                     ||           d|z  }d|z  }|                     ||           Cd S )Nz	a.func_%sa.__%s__zself.foo.func_%s.foo_barself.foo.__%s__.foo_barattrsr)   r   attrrT   rU   s       r   r   zTest_funcattrs.test^  sp    J 	 	Dd"AT!AJJq!*T1A)D0AJJq!	 	r   c                     | j         D ]P}d|z  }|                     |           d|z  }|                     |           d|z  }|                     |           Qd S )Nzfoo(func_%s + 5)f(foo.__%s__)f(foo.__%s__.foo)r7  r/   r   r9  r   s      r   r   zTest_funcattrs.test_unchangedh  st    J 	 	D"T)ANN1$&ANN1#d*ANN1	 	r   NrL   r=   rM   r   r7  r   r   r;   r   r   r+  r+  Y  sB        EMMME  	 	 	 	 	r   r+  c                   $    e Zd ZdZd Zd Zd ZdS )Test_xreadlines
xreadlinesc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzfor x in f.xreadlines(): passzfor x in f: passz!for x in foo().xreadlines(): passzfor x in foo(): passz'for x in (5 + foo()).xreadlines(): passzfor x in (5 + foo()): passrR   rS   s      r   r   zTest_xreadlines.test_callv  sb    +

1a/"

1a5(

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzfoo(f.xreadlines + 5)zfoo(f.__iter__ + 5)zfoo(f().xreadlines + 5)zfoo(f().__iter__ + 5)zfoo((5 + f()).xreadlines + 5)zfoo((5 + f()).__iter__ + 5)rR   rS   s      r   test_attr_refzTest_xreadlines.test_attr_ref  sb    #!

1a%#

1a+)

1ar   c                     d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzfor x in f.xreadlines(5): passz for x in f.xreadlines(k=5): passz$for x in f.xreadlines(*k, **v): passzfoo(xreadlines)r2   r   s     r   r   zTest_xreadlines.test_unchanged  sd    ,q.q2qqr   N)rL   r=   rM   r   r   rE  r   r;   r   r   rA  rA  s  sF        E        r   rA  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )ImportsFixerTestsc                     | j                                         D ]E\  }}d|z  }d|z  }|                     ||           d|z  }d|z  }|                     ||           Fd S )N	import %szimport foo, %s, barmodulesitemsr)   r   oldnewrT   rU   s        r   test_import_modulez$ImportsFixerTests.test_import_module  s    **,, 	 	HCc!Ac!AJJq!%+A%+AJJq!	 	r   c                    | j                                         D ]e\  }}d|z  }d|z  }|                     ||           d|z  }d|z  }|                     ||           d|z  }d|z  }|                     ||           fd S )Nzfrom %s import foozfrom %s import foo, barzfrom %s import (yes, no)rK  rN  s        r   test_import_fromz"ImportsFixerTests.test_import_from  s    **,, 	 	HC$s*A$s*AJJq!)C/A)C/AJJq!*S0A*S0AJJq!	 	r   c                     | j                                         D ]E\  }}d|z  }d|z  }|                     ||           d|z  }d|z  }|                     ||           Fd S )Nzimport %s as foo_barrK  rN  s        r   test_import_module_asz'ImportsFixerTests.test_import_module_as  s    **,, 	 	HC&,A&,AJJq!&,A&,AJJq!	 	r   c                     | j                                         D ]%\  }}d|z  }d|z  }|                     ||           &d S )Nzfrom %s import foo as barrK  rN  s        r   test_import_from_asz%ImportsFixerTests.test_import_from_as  sX    **,, 	 	HC+c1A+c1AJJq!	 	r   c                     | j                                         D ]%\  }}d|z  }d|z  }|                     ||           &d S )Nfrom %s import *rK  rN  s        r   	test_starzImportsFixerTests.test_star  sX    **,, 	 	HC"S(A"S(AJJq!	 	r   c                    | 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 S )N
                import 
                foo(z.bar)
                
                from z import x
                z = 23
                z.
                def f():
                    z.method()
                z
                z.bar(z.foo)
                z
                x.)rL  rM  r)   r/   )r   rO  rP  rT   rU   r   s         r   test_import_module_usagez*ImportsFixerTests.test_import_module_usage  s   **,, .	 .	HC ssCCC!AA ssCCC!A JJq!
 ssCCC!AA ssCCC!A JJq!
 ssA NN1 ssCCC&AA ssCCC&A JJq!
 ssCCC!AA ssCCC!A JJq!].	 .	r   N)	rL   r=   rM   rQ  rS  rU  rW  rZ  r_  r;   r   r   rH  rH    sn                  / / / / /r   rH  c                   *    e Zd ZdZddlmZ d Zd ZdS )Test_importsimports   MAPPINGc                 :    d}d}|                      ||           d S )Nzimport urlparse, cStringIOzimport urllib.parse, iorR   rS   s      r   test_multiple_importsz"Test_imports.test_multiple_imports  s&    ,)

1ar   c                 :    d}d}|                      ||           d S )Nzv
            import copy_reg as bar, HTMLParser as foo, urlparse
            s = urlparse.spam(bar.foo())
            z~
            import copyreg as bar, html.parser as foo, urllib.parse
            s = urllib.parse.spam(bar.foo())
            rR   rS   s      r   test_multiple_imports_asz%Test_imports.test_multiple_imports_as	  ,     	

1ar   N)	rL   r=   rM   r   fixes.fix_importsre  rL  rg  ri  r;   r   r   ra  ra     sI        E666666  
	 	 	 	 	r   ra  c                       e Zd ZdZddlmZ dS )Test_imports2imports2rc  rd  N)rL   r=   rM   r   fixes.fix_imports2re  rL  r;   r   r   rm  rm    s'        E77777777r   rm  c                   $     e Zd Z fdZd Z xZS )Test_imports_fixer_orderc                     t          t          |                               ddg           ddlm} |                                | _        ddlm} dD ]}||         | j        |<   d S )Nrb  rn  rc  rd  )dbhashdumbdbmdbmgdbm)r  rq  r   ro  re  copyrL  rk  )r   mapping2mapping1keyr<   s       r   r   zTest_imports_fixer_order.setUp  s    &--33Y
4KLLL<<<<<<}};;;;;;7 	. 	.C (DL	. 	.r   c                 H    dD ]}|| _         |                     d           d S )N)rb  rn  import)r   rK   )r   fixs     r   $test_after_local_imports_refactoringz=Test_imports_fixer_order.test_after_local_imports_refactoring$  s9    * 	- 	-CDJ""8,,,,	- 	-r   )rL   r=   rM   r   r~  r  r  s   @r   rq  rq    sG        . . . . .- - - - - - -r   rq  c                   N    e Zd ZdZddlmZ d Zd Zd Z	d Z
d Zd	 Zd
 Zd ZdS )Test_urlliburllibrc  rd  c           	          | j                                         D ]S\  }}d|z  }dd                    t          t	          d          |                    z  }|                     ||           Td S )NrJ  r9   r   )rL  rM  r-   mapr   r)   )r   rO  changesrT   rU   s        r   rQ  zTest_urllib.test_import_module.  st     L..00 	 	LCc!AdiiJqMM7(C(CDDDAJJq!	 	r   c                    | j                                         D ]3\  }}g }|D ]\  }}|D ]W}|                    |           d|d|}d|d|}|                     ||           d|z  }	|                     |	           Xd|dd                    |          }d|dd                    |          }|                     ||           dd                    |          z  }	|                     |	           d|dd                    |          }d                    d |D                       }|                     ||           5d S )Nfrom  import from foo import %sr9   
c                 J    g | ] \  }}d |dd                     |          !S )r  r  r9   )r-   )r>   rP  memberss      r   r@   z0Test_urllib.test_import_from.<locals>.<listcomp>J  sF     ; ; ; .gg 36##tyy7I7I7IJ ; ; ;r   )rL  rM  appendr)   r/   r-   )
r   rO  r  all_membersrP  r  memberrT   rU   r   s
             r   rS  zTest_urllib.test_import_from4  s    L..00 	 	LCK ' " "W% & &F&&v..../2ssFF;AA/2ssFF;AJJq!$$$,v5ANN1%%%%& ,/33		'0B0B0BC+.33		'0B0B0BC

1a   (499W+=+==q!!!!"$ (+ssDIIk,B,B,BCA		 ; ;29; ; ; < <AJJq!/	 	r   c                 P    | j         D ]}d|z  }|                     |d           d S )Nzimport %s as fooz#This module is now multiple modulesrL  r4   r   rO  r   s      r   rU  z!Test_urllib.test_import_module_asN  sE    < 	K 	KC"S(A  $IJJJJ	K 	Kr   c           	         | j                                         D ]f\  }}|D ]^\  }}|D ]V}d|d|d}d|d|d}|                     ||           d|d|d|}d|d|d|}|                     ||           W_gd S )Nr  r   as foo_barz
 as blah, rK  )r   rO  r  rP  r  r  rT   rU   s           r   rW  zTest_urllib.test_import_from_asS  s     L..00 	% 	%LC ' % %W% % %FF:=##vvvFAA:=##vvvFAJJq!$$$$;>33OAA;>33OAJJq!$$$$%%	% 	%r   c                 P    | j         D ]}d|z  }|                     |d           d S )NrY  zCannot handle star importsr  r  s      r   rZ  zTest_urllib.test_star^  sE    < 	B 	BC"S(A  $@AAAA	B 	Br   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nz6
def foo():
    from urllib import urlencode, urlopen
zZ
def foo():
    from urllib.parse import urlencode
    from urllib.request import urlopen
zB
def foo():
    other()
    from urllib import urlencode, urlopen
zf
def foo():
    other()
    from urllib.parse import urlencode
    from urllib.request import urlopen
rR   rS   s      r   test_indentedzTest_urllib.test_indentedc  sP    
 	

1a
 	

1ar   c                 :    d}d}|                      ||           d S )Nzfrom urllib import getproxiesz%from urllib.request import getproxiesrR   rS   s      r   test_single_importzTest_urllib.test_single_import|  s&    +3

1ar   c                    | j                                         D ]\  }}|D ]\  }}|D ]}d                    d | j         |         D                       }d|d|d|d}d|d|d|d}|                     ||           d|d|d|d|d|d}d|d|d|d|d|d}|                     ||           d S )	Nr9   c                     g | ]\  }}|S r;   r;   )r>   rJ   memss      r   r@   z8Test_urllib.test_import_module_usage.<locals>.<listcomp>  s.     ,B ,B ,B)1dA ,B ,B ,Br   z 
                        import z
                        foo(.z)
                        z
                        ()rL  rM  r-   r)   )	r   rO  r  rP  r  r  
new_importrT   rU   s	            r   r_  z$Test_urllib.test_import_module_usage  sW    L..00 	% 	%LC ' % %W% % %F!% ,B ,B/3|C/@,B ,B ,B "C "CJJ
  #ssCCC1AA  *zz3338A JJq!$$$$  #ssCCCfff>AA  *zz333VVVEA JJq!$$$$)%%	% 	%r   N)rL   r=   rM   r   fixes.fix_urllibre  rL  rQ  rS  rU  rW  rZ  r  r  r_  r;   r   r   r  r  *  s        E555555    4K K K
	% 	% 	%B B B
  2  % % % % %r   r  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )

Test_inputinputc                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzx =   input(   )zx =   eval(input(   ))r  zx = eval(input(   ''   ))rR   rS   s      r   r   z#Test_input.test_prefix_preservation  sD    "(

1a%+

1ar   c                 :    d}d}|                      ||           d S )Nzx = input()  #  foozx = eval(input())  #  foorR   rS   s      r   r  z Test_input.test_trailing_comment  &    %+

1ar   c                     d}|                      |           d}|                      |           d}|                      |           d S )Nx = eval(input())x = eval(input(''))x = eval(input(foo(5) + 9))r2   r   s     r   r   zTest_input.test_idempotency  sM    #q%q-qr   c                 :    d}d}|                      ||           d S )Nr!  r  rR   rS   s      r   r`   zTest_input.test_1  s&    #

1ar   c                 :    d}d}|                      ||           d S )Nr#  r  rR   rS   s      r   rb   zTest_input.test_2  r  r   c                 :    d}d}|                      ||           d S )Nr%  zx = eval(input('prompt'))rR   rS   s      r   re   zTest_input.test_3  r  r   c                 :    d}d}|                      ||           d S )Nzx = input(foo(5) + 9)r  rR   rS   s      r   rg   zTest_input.test_4  s&    '-

1ar   N)rL   r=   rM   r   r   r  r   r`   rb   re   rg   r;   r   r   r  r    s        E    
    
  
  
    r   r  c                       e 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S )Test_tuple_paramstuple_paramsc                 4    d}|                      |           d S )Nzdef foo(): passr2   r   s     r   r   z"Test_tuple_params.test_unchanged_1  r   r   c                 4    d}|                      |           d S )Nzdef foo(a, b, c): passr2   r   s     r   r   z"Test_tuple_params.test_unchanged_2  s    (qr   c                 4    d}|                      |           d S )Nzdef foo(a=3, b=4, c=5): passr2   r   s     r   r   z"Test_tuple_params.test_unchanged_3  r   r   c                 :    d}d}|                      ||           d S )Nz8
            def foo(((a, b), c)):
                x = 5zn
            def foo(xxx_todo_changeme):
                ((a, b), c) = xxx_todo_changeme
                x = 5rR   rS   s      r   r`   zTest_tuple_params.test_1  ,     	

1ar   c                 :    d}d}|                      ||           d S )Nz;
            def foo(((a, b), c), d):
                x = 5zq
            def foo(xxx_todo_changeme, d):
                ((a, b), c) = xxx_todo_changeme
                x = 5rR   rS   s      r   rb   zTest_tuple_params.test_2  r  r   c                 :    d}d}|                      ||           d S )Nz@
            def foo(((a, b), c), d) -> e:
                x = 5zv
            def foo(xxx_todo_changeme, d) -> e:
                ((a, b), c) = xxx_todo_changeme
                x = 5rR   rS   s      r   re   zTest_tuple_params.test_3  r  r   c                 :    d}d}|                      ||           d S )Nz/
            def foo(((a, b), c)): x = 5; y = 7zV
            def foo(xxx_todo_changeme): ((a, b), c) = xxx_todo_changeme; x = 5; y = 7rR   rS   s      r   test_semicolonz Test_tuple_params.test_semicolon  s+    2Y

1ar   c                 :    d}d}|                      ||           d S )NzE
            def foo(((a, b), c), d, e=5) -> z:
                x = 5z{
            def foo(xxx_todo_changeme, d, e=5) -> z:
                ((a, b), c) = xxx_todo_changeme
                x = 5rR   rS   s      r   test_keywordszTest_tuple_params.test_keywords  r  r   c                 :    d}d}|                      ||           d S )NzR
            def foo(((a, b), c), d, *vargs, **kwargs) -> z:
                x = 5z
            def foo(xxx_todo_changeme, d, *vargs, **kwargs) -> z:
                ((a, b), c) = xxx_todo_changeme
                x = 5rR   rS   s      r   test_varargszTest_tuple_params.test_varargs  r  r   c                 :    d}d}|                      ||           d S )NzH
            def foo(((a, b), c), (d, e, f)) -> z:
                x = 5z
            def foo(xxx_todo_changeme, xxx_todo_changeme1) -> z:
                ((a, b), c) = xxx_todo_changeme
                (d, e, f) = xxx_todo_changeme1
                x = 5rR   rS   s      r   test_multi_1zTest_tuple_params.test_multi_1  ,    
 	

1ar   c                 :    d}d}|                      ||           d S )NzQ
            def foo(x, ((a, b), c), d, (e, f, g), y) -> z:
                x = 5z
            def foo(x, xxx_todo_changeme, d, xxx_todo_changeme1, y) -> z:
                ((a, b), c) = xxx_todo_changeme
                (e, f, g) = xxx_todo_changeme1
                x = 5rR   rS   s      r   test_multi_2zTest_tuple_params.test_multi_2%  r  r   c                 :    d}d}|                      ||           d S )Nzj
            def foo(((a, b), c), (d, e, f)) -> z:
                "foo foo foo foo"
                x = 5z
            def foo(xxx_todo_changeme, xxx_todo_changeme1) -> z:
                "foo foo foo foo"
                ((a, b), c) = xxx_todo_changeme
                (d, e, f) = xxx_todo_changeme1
                x = 5rR   rS   s      r   test_docstringz Test_tuple_params.test_docstring1  s,    
 	

1ar   c                 4    d}|                      |           d S )Nlambda x: x + 5r2   r   s     r   test_lambda_no_changez'Test_tuple_params.test_lambda_no_change?  r   r   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzlambda (x): x + 5r  zlambda(x): x + 5zlambda ((((x)))): x + 5zlambda((((x)))): x + 5rR   rS   s      r   test_lambda_parens_single_argz/Test_tuple_params.test_lambda_parens_single_argC  s    #!

1a"!

1a)!

1a(!

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzlambda (x, y): x + f(y)zlambda x_y: x_y[0] + f(x_y[1])zlambda(x, y): x + f(y)zlambda (((x, y))): x + f(y)zlambda(((x, y))): x + f(y)rR   rS   s      r   test_lambda_simplez$Test_tuple_params.test_lambda_simpleT  s    )0

1a(0

1a-0

1a,0

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzlambda (x,): x + f(x)zlambda x1: x1[0] + f(x1[0])zlambda (((x,))): x + f(x)rR   rS   s      r   test_lambda_one_tuplez'Test_tuple_params.test_lambda_one_tuplee  sD    '-

1a+-

1ar   c                 :    d}d}|                      ||           d S )Nzlambda (x, y): x + x + f(x) + xz0lambda x_y: x_y[0] + x_y[0] + f(x_y[0]) + x_y[0]rR   rS   s      r   test_lambda_simple_multi_usez.Test_tuple_params.test_lambda_simple_multi_usen  s&    1B

1ar   c                 :    d}d}|                      ||           d S )Nzlambda (x, y): y + xzlambda x_y: x_y[1] + x_y[0]rR   rS   s      r   test_lambda_simple_reversez,Test_tuple_params.test_lambda_simple_reverses  s&    &-

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzlambda (x, (y, z)): x + y + zz2lambda x_y_z: x_y_z[0] + x_y_z[1][0] + x_y_z[1][1]z!lambda (((x, (y, z)))): x + y + zrR   rS   s      r   test_lambda_nestedz$Test_tuple_params.test_lambda_nestedx  sD    /D

1a3D

1ar   c                 :    d}d}|                      ||           d S )Nz lambda (x, (y, z)): x + y + f(y)z5lambda x_y_z: x_y_z[0] + x_y_z[1][0] + f(x_y_z[1][0])rR   rS   s      r   test_lambda_nested_multi_usez.Test_tuple_params.test_lambda_nested_multi_use  s&    2G

1ar   N)rL   r=   rM   r   r   r   r   r`   rb   re   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r;   r   r   r  r    sE       E      	 	 		 	 		 	 	  	 	 		 	 	
 
 

 
 
      "  "    
  
      r   r  c                   &    e Zd ZdZg dZd Zd ZdS )Test_methodattrsmethodattrs)funcr   classc                     | j         D ]T}d|z  }|dk    rd}nd|z  }|                     ||           d|z  }|dk    rd}nd|z  }|                     ||           Ud S )Nza.im_%sr  za.__self__.__class__r4  zself.foo.im_%s.foo_barz#self.foo.__self__.__class__.foo_barr5  r6  r8  s       r   r   zTest_methodattrs.test  s    J 	 	DD Aw*%JJq!(4/Aw9-4JJq!	 	r   c                     | j         D ]P}d|z  }|                     |           d|z  }|                     |           d|z  }|                     |           Qd S )Nzfoo(im_%s + 5)r;  r<  r=  r>  s      r   r   zTest_methodattrs.test_unchanged  st    J 	 	D 4'ANN1$&ANN1#d*ANN1	 	r   Nr?  r;   r   r   r  r    sB        E%%%E   	 	 	 	 	r   r  c                       e 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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. Z0d/S )0	Test_nextnextc                 :    d}d}|                      ||           d S )Nz	it.next()znext(it)rR   rS   s      r   r`   zTest_next.test_1  &    

1ar   c                 :    d}d}|                      ||           d S )Nza.b.c.d.next()znext(a.b.c.d)rR   rS   s      r   rb   zTest_next.test_2  r  r   c                 :    d}d}|                      ||           d S )Nz(a + b).next()znext((a + b))rR   rS   s      r   re   zTest_next.test_3  r  r   c                 :    d}d}|                      ||           d S )Nz
a().next()z	next(a())rR   rS   s      r   rg   zTest_next.test_4  &    

1ar   c                 :    d}d}|                      ||           d S )Nza().next() + bznext(a()) + brR   rS   s      r   ri   zTest_next.test_5  r  r   c                 :    d}d}|                      ||           d S )Nzc(      a().next() + b)zc(      next(a()) + b)rR   rS   s      r   rl   zTest_next.test_6  r  r   c                 :    d}d}|                      ||           d S )NzU
            for a in b:
                foo(a)
                a.next()
            zT
            for a in b:
                foo(a)
                next(a)
            rR   rS   s      r   test_prefix_preservation_1z$Test_next.test_prefix_preservation_1  ,    

 	

1ar   c                 :    d}d}|                      ||           d S )Nzq
            for a in b:
                foo(a) # abc
                # def
                a.next()
            zp
            for a in b:
                foo(a) # abc
                # def
                next(a)
            rR   rS   s      r   test_prefix_preservation_2z$Test_next.test_prefix_preservation_2  s,     	

1ar   c                 >    d}d}|                      ||d           d S )Nzj
            next = 5
            for a in b:
                foo(a)
                a.next()
            zn
            next = 5
            for a in b:
                foo(a)
                a.__next__()
            Tr(   rR   rS   s      r   test_prefix_preservation_3z$Test_next.test_prefix_preservation_3  0     	

1a
.....r   c                 >    d}d}|                      ||d           d S )Nz
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.next()
            z
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.__next__()
            Tr  rR   rS   s      r   test_prefix_preservation_4z$Test_next.test_prefix_preservation_4  s0     	

1a
.....r   c                 >    d}d}|                      ||d           d S )Nzz
            next = 5
            for a in b:
                foo(foo(a), # abc
                    a.next())
            z~
            next = 5
            for a in b:
                foo(foo(a), # abc
                    a.__next__())
            Tr  rR   rS   s      r   test_prefix_preservation_5z$Test_next.test_prefix_preservation_5	  r  r   c                 :    d}d}|                      ||           d S )Nze
            for a in b:
                foo(foo(a), # abc
                    a.next())
            zd
            for a in b:
                foo(foo(a), # abc
                    next(a))
            rR   rS   s      r   test_prefix_preservation_6z$Test_next.test_prefix_preservation_6	  r  r   c                 :    d}d}|                      ||           d S )Nz[
            class A:
                def next(self):
                    pass
            z_
            class A:
                def __next__(self):
                    pass
            rR   rS   s      r   test_method_1zTest_next.test_method_1	  r  r   c                 :    d}d}|                      ||           d S )Nzc
            class A(object):
                def next(self):
                    pass
            zg
            class A(object):
                def __next__(self):
                    pass
            rR   rS   s      r   test_method_2zTest_next.test_method_2,	  r  r   c                 :    d}d}|                      ||           d S )NzX
            class A:
                def next(x):
                    pass
            z\
            class A:
                def __next__(x):
                    pass
            rR   rS   s      r   test_method_3zTest_next.test_method_39	  r  r   c                 :    d}d}|                      ||           d S )Nz
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def next(self):
                    pass

                def __iter__(self):
                    return self
            z
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def __next__(self):
                    pass

                def __iter__(self):
                    return self
            rR   rS   s      r   test_method_4zTest_next.test_method_4F	  s,    

 	

1ar   c                 4    d}|                      |           d S )Nza
            class A:
                def next(self, a, b):
                    pass
            r2   r   s     r   test_method_unchangedzTest_next.test_method_unchanged_	  #    
 	qr   c                 6    d}|                      |d           d S )Nzy
            next = foo

            class A:
                def next(self, a, b):
                    pass
            )Calls to builtin next() possibly shadowedrW  r   s     r   test_shadowing_assign_simplez&Test_next.test_shadowing_assign_simpleg	  (     	Q KLLLLLr   c                 6    d}|                      |d           d S )Nz~
            (next, a) = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_assign_tuple_1z'Test_next.test_shadowing_assign_tuple_1q	  r  r   c                 6    d}|                      |d           d S )Nz
            (a, (b, (next, c)), a) = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_assign_tuple_2z'Test_next.test_shadowing_assign_tuple_2{	  r  r   c                 6    d}|                      |d           d S )Nz~
            [next, a] = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_assign_list_1z&Test_next.test_shadowing_assign_list_1	  r  r   c                 6    d}|                      |d           d S )Nz
            [a, [b, [next, c]], a] = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_assign_list_2z&Test_next.test_shadowing_assign_list_2	  r  r   c                 6    d}|                      |d           d S )Nz
            def foo():
                __builtin__.next = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_builtin_assignzTest_next.test_builtin_assign	  (     	Q KLLLLLr   c                 6    d}|                      |d           d S )Nz
            def foo():
                (a, __builtin__.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_builtin_assign_in_tuplez&Test_next.test_builtin_assign_in_tuple	  r  r   c                 6    d}|                      |d           d S )Nz
            def foo():
                [a, __builtin__.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_builtin_assign_in_listz%Test_next.test_builtin_assign_in_list	  r  r   c                 4    d}|                      |           d S )Nz
            def foo():
                A.next = foo

            class A:
                def next(self, a, b):
                    pass
            r2   r   s     r   test_assign_to_nextzTest_next.test_assign_to_next	  #     	qr   c                 4    d}|                      |           d S )Nz
            def foo():
                (a, A.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r2   r   s     r   test_assign_to_next_in_tuplez&Test_next.test_assign_to_next_in_tuple	  r  r   c                 4    d}|                      |           d S )Nz
            def foo():
                [a, A.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r2   r   s     r   test_assign_to_next_in_listz%Test_next.test_assign_to_next_in_list	  r  r   c                 6    d}|                      |d           d S )Nz
            import foo.bar as next

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_1z!Test_next.test_shadowing_import_1	  r  r   c                 6    d}|                      |d           d S )Nz
            import bar, bar.foo as next

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_2z!Test_next.test_shadowing_import_2	  r  r   c                 6    d}|                      |d           d S )Nz
            import bar, bar.foo as next, baz

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_3z!Test_next.test_shadowing_import_3	  r  r   c                 6    d}|                      |d           d S )Nz
            from x import next

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_from_1z&Test_next.test_shadowing_import_from_1	  r  r   c                 6    d}|                      |d           d S )Nz
            from x.a import next

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_from_2z&Test_next.test_shadowing_import_from_2
  r  r   c                 6    d}|                      |d           d S )Nz
            from x import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_from_3z&Test_next.test_shadowing_import_from_3
  r  r   c                 6    d}|                      |d           d S )Nz
            from x.a import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_import_from_4z&Test_next.test_shadowing_import_from_4
  r  r   c                 6    d}|                      |d           d S )Nz
            def next(a):
                pass

            class A:
                def next(self, a, b):
                    pass
            r  rW  r   s     r   test_shadowing_funcdef_1z"Test_next.test_shadowing_funcdef_1!
  r  r   c                 <    d}d}|                      ||d           d S )Nz
            def next(a):
                pass

            class A:
                def next(self):
                    pass

            it.next()
            z
            def next(a):
                pass

            class A:
                def __next__(self):
                    pass

            it.__next__()
            r  r3   rS   s      r   test_shadowing_funcdef_2z"Test_next.test_shadowing_funcdef_2,
  s/    		 	

1aDEEEEEr   c                 6    d}|                      |d           d S )NzW
            def f():
                global next
                next = 5
            r  rW  r   s     r   test_shadowing_global_1z!Test_next.test_shadowing_global_1C
  (    
 	Q KLLLLLr   c                 6    d}|                      |d           d S )Nz]
            def f():
                global a, next, b
                next = 5
            r  rW  r   s     r   test_shadowing_global_2z!Test_next.test_shadowing_global_2K
  r0  r   c                 6    d}|                      |d           d S )Nze
            for next in it():
                pass

            b = 5
            c = 6
            r  rW  r   s     r   test_shadowing_for_simplez#Test_next.test_shadowing_for_simpleS
  r  r   c                 6    d}|                      |d           d S )Nzh
            for next, b in it():
                pass

            b = 5
            c = 6
            r  rW  r   s     r   test_shadowing_for_tuple_1z$Test_next.test_shadowing_for_tuple_1]
  r  r   c                 6    d}|                      |d           d S )Nzp
            for a, (next, c), b in it():
                pass

            b = 5
            c = 6
            r  rW  r   s     r   test_shadowing_for_tuple_2z$Test_next.test_shadowing_for_tuple_2g
  r  r   c                 :    d}d}|                      ||           d S )Nzgnext = g.nextzgnext = g.__next__rR   rS   s      r   test_noncall_access_1zTest_next.test_noncall_access_1q
  &     $

1ar   c                 :    d}d}|                      ||           d S )Nzf(g.next + 5)zf(g.__next__ + 5)rR   rS   s      r   test_noncall_access_2zTest_next.test_noncall_access_2v
  r  r   c                 :    d}d}|                      ||           d S )Nzf(g().next + 5)zf(g().__next__ + 5)rR   rS   s      r   test_noncall_access_3zTest_next.test_noncall_access_3{
  s&    !%

1ar   N)1rL   r=   rM   r   r`   rb   re   rg   ri   rl   r  r  r  r  r  r  r  r  r  r  r   r  r  r	  r  r  r  r  r  r  r  r  r  r  r!  r#  r%  r'  r)  r+  r-  r/  r2  r4  r6  r8  r:  r=  r?  r;   r   r   r  r    s       E  
  
  
  
  
  
    / / // / /"/ / /          2  M M MM M MM M MM M MM M M	M 	M 	M	M 	M 	M	M 	M 	M	 	 		 	 		 	 	M M MM M MM M MM M MM M MM M MM M M	M 	M 	MF F F.M M MM M MM M MM M MM M M  
  
    r   r  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )Test_nonzerononzeroc                 :    d}d}|                      ||           d S )Nzb
            class A:
                def __nonzero__(self):
                    pass
            z_
            class A:
                def __bool__(self):
                    pass
            rR   rS   s      r   r`   zTest_nonzero.test_1
  r  r   c                 :    d}d}|                      ||           d S )Nzj
            class A(object):
                def __nonzero__(self):
                    pass
            g
            class A(object):
                def __bool__(self):
                    pass
            rR   rS   s      r   rb   zTest_nonzero.test_2
  r  r   c                 4    d}|                      |           d S )NrE  r2   r   s     r   r   zTest_nonzero.test_unchanged_1
  r  r   c                 4    d}|                      |           d S )Nzm
            class A(object):
                def __nonzero__(self, a):
                    pass
            r2   r   s     r   r   zTest_nonzero.test_unchanged_2
  r  r   c                 4    d}|                      |           d S )NzE
            def __nonzero__(self):
                pass
            r2   r   s     r   test_unchanged_funcz Test_nonzero.test_unchanged_func
  s#     	qr   N)	rL   r=   rM   r   r`   rb   r   r   rI  r;   r   r   rA  rA  
  sd        E            r   rA  c                   `    e 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S )Test_numliteralsnumliteralsc                 :    d}d}|                      ||           d S )N07550o755rR   rS   s      r   test_octal_1zTest_numliterals.test_octal_1
  s&    

1ar   c                 :    d}d}|                      ||           d S )Nza = 12La = 12rR   rS   s      r   test_long_int_1z Test_numliterals.test_long_int_1
  &    

1ar   c                 :    d}d}|                      ||           d S )Nza = 12lrR  rR   rS   s      r   test_long_int_2z Test_numliterals.test_long_int_2
  rT  r   c                 :    d}d}|                      ||           d S )Nz	b = 0x12lzb = 0x12rR   rS   s      r   test_long_hexzTest_numliterals.test_long_hex
  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzb =   0x12Lz
b =   0x12zb = 0755 # spamzb = 0o755 # spamrR   rS   s      r   test_comments_and_spacingz*Test_numliterals.test_comments_and_spacing
  sD    

1a!"

1ar   c                 4    d}|                      |           d S )N5r2   r   s     r   test_unchanged_intz#Test_numliterals.test_unchanged_int
  s    qr   c                 4    d}|                      |           d S )Nz5.0r2   r   s     r   test_unchanged_floatz%Test_numliterals.test_unchanged_float
  s    qr   c                 4    d}|                      |           d S )NrO  r2   r   s     r   test_unchanged_octalz%Test_numliterals.test_unchanged_octal
      qr   c                 4    d}|                      |           d S )N0xABCr2   r   s     r   test_unchanged_hexz#Test_numliterals.test_unchanged_hex
  rb  r   c                 4    d}|                      |           d S )Nz5.0e10r2   r   s     r   test_unchanged_expz#Test_numliterals.test_unchanged_exp
      qr   c                 4    d}|                      |           d S )Nz5 + 4jr2   r   s     r   test_unchanged_complex_intz+Test_numliterals.test_unchanged_complex_int
  rh  r   c                 4    d}|                      |           d S )Nz
5.4 + 4.9jr2   r   s     r   test_unchanged_complex_floatz-Test_numliterals.test_unchanged_complex_float
  r	  r   c                 b    d}|                      |           d}|                      |           d S )N4jz4.4jr2   r   s     r   test_unchanged_complex_barez,Test_numliterals.test_unchanged_complex_bare
  s6    qqr   N)rL   r=   rM   r   rP  rS  rV  rX  rZ  r]  r_  ra  re  rg  rj  rl  ro  r;   r   r   rK  rK  
  s        E  
  
  
  
                    r   rK  c                   2    e Zd ZdZddiZd Zd Zd Zd ZdS )	Test_renamesrenamessys)maxintmaxsizec                     t          | j                                                  D ]H\  }\  }}d|d|}d|d|}|                     ||           d|z  }|                     |           Id S )Nr  r  r  )listrL  rM  r)   r/   )r   modrO  rP  rT   rU   r   s          r   rS  zTest_renames.test_import_from
  s    #DL$6$6$8$899 	 	OC#ss'*ssCC0AA'*ssCC0AJJq!$s*ANN1	 	r   c                     t          | j                                                  D ]0\  }\  }}d|d|d}d|d|d}|                     ||           1d S )Nr  r  r  rw  rL  rM  r)   r   rx  rO  rP  rT   rU   s         r   rW  z Test_renames.test_import_from_as  sx    #DL$6$6$8$899 	 	OC#ss25##sss;AA25##sss;AJJq!	 	r   c           
          t          | j                                                  D ]<\  }\  }}d|d|d|d|d	}d|d|d|d|d	}|                     ||           =d S )Nr\  r]  r9   r  )
                rz  r{  s         r   r_  z%Test_renames.test_import_module_usage  s    #DL$6$6$8$899 		 		OC#ss ssCCCccc+AA ssCCCccc+A JJq!		 		r   c           
          t          | j                                                  D ]<\  }\  }}d|d|d|d|d	}d|d|d|d|d	}|                     ||           =d S )Nr^  r  r]  r9   r}  rz  r{  s         r   XXX_test_from_import_usagez'Test_renames.XXX_test_from_import_usage  s    #DL$6$6$8$899 		 		OC#ss ssCCCccc+AA ssCCCccc+A JJq!		 		r   N)	rL   r=   rM   r   rL  rS  rW  r_  r  r;   r   r   rq  rq  
  sb        E, G    
 
 
    r   rq  c                   N    e 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S )Test_unicodeunicodec                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzunicode( x)zstr( x)z unicode(x )z str(x )z u'h'z 'h'rR   rS   s      r   test_whitespacezTest_unicode.test_whitespace'  sb    

1a

1a

1ar   c                 :    d}d}|                      ||           d S )Nzunicode(x, y, z)zstr(x, y, z)rR   rS   s      r   test_unicode_callzTest_unicode.test_unicode_call4  r  r   c                 :    d}d}|                      ||           d S )Nzunichr(u'h')zchr('h')rR   rS   s      r   test_unichrzTest_unicode.test_unichr9  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzu"x"z"x"rR   rS   s      r   test_unicode_literal_1z#Test_unicode.test_unicode_literal_1>  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzur'x'zr'x'rR   rS   s      r   test_unicode_literal_2z#Test_unicode.test_unicode_literal_2C  s&    

1ar   c                 :    d}d}|                      ||           d S )Nz
UR'''x''' z	R'''x''' rR   rS   s      r   test_unicode_literal_3z#Test_unicode.test_unicode_literal_3H  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )N'\\\u20ac\U0001d121\\u20ac'z'\\\\u20ac\\U0001d121\\u20ac'r'\\\u20ac\U0001d121\\u20ac'rR   rS   s      r   test_native_literal_escape_uz)Test_unicode.test_native_literal_escape_uM  sD    .0

1a//

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzb'\\\u20ac\U0001d121\\u20ac'zbr'\\\u20ac\U0001d121\\u20ac'rR   rS   s      r   test_bytes_literal_escape_uz(Test_unicode.test_bytes_literal_escape_uV  sD    //

1a00

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzu'\\\u20ac\U0001d121\\u20ac'r  zur'\\\u20ac\U0001d121\\u20ac'r  rR   rS   s      r   test_unicode_literal_escape_uz*Test_unicode.test_unicode_literal_escape_u_  sD    /.

1a0/

1ar   c                     d}|dz   }|dz   }|                      ||           |dz   }|dz   }|                      ||           d S )Nz(from __future__ import unicode_literals
r  r  rR   )r   frT   rU   s       r   $test_native_unicode_literal_escape_uz1Test_unicode.test_native_unicode_literal_escape_uh  sa    72222

1a3333

1ar   N)rL   r=   rM   r   r  r  r  r  r  r  r  r  r  r  r;   r   r   r  r  $  s        E    
  
  
  
  
          r   r  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )Test_filterfilterc                 n    d}d}|                      ||           d}d}|                      ||           d S )Nz#x =   filter(    foo,     'abc'   )z)x =   list(filter(    foo,     'abc'   ))zx =   filter(  None , 'abc'  )z x =   [_f for _f in 'abc' if _f]rR   rS   s      r   r   z$Test_filter.test_prefix_preservationv  sD    5;

1a02

1ar   c                 
   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d	}|                      ||           d S )
Nzx = filter(None, 'abc')zx = [_f for _f in 'abc' if _f]zx = len(filter(f, 'abc'))zx = len(list(filter(f, 'abc')))z)x = filter(lambda x: x%2 == 0, range(10))z&x = [x for x in range(10) if x%2 == 0]z+x = filter(lambda (x): x%2 == 0, range(10))z5filter(lambda x: True if x > 2 else False, [1, 2, 3])z4[x for x in [1, 2, 3] if (True if x > 2 else False)]rR   rS   s      r   test_filter_basiczTest_filter.test_filter_basic  s    )0

1a+1

1a;8

1a >8

1a HF

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzx = filter(None, 'abc')[0]z!x = [_f for _f in 'abc' if _f][0]zx = len(filter(f, 'abc')[0])z"x = len(list(filter(f, 'abc'))[0])z,x = filter(lambda x: x%2 == 0, range(10))[0]z)x = [x for x in range(10) if x%2 == 0][0]z.x = filter(lambda (x): x%2 == 0, range(10))[0]rR   rS   s      r   test_filter_trailersz Test_filter.test_filter_trailers  s    ,3

1a.4

1a>;

1a A;

1ar   c                 p   d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d	}|                      |           d
}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzb.join(filter(f, 'abc'))z#(a + foo(5)).join(filter(f, 'abc'))ziter(filter(f, 'abc'))zlist(filter(f, 'abc'))zlist(filter(f, 'abc'))[0]zset(filter(f, 'abc'))zset(filter(f, 'abc')).pop()ztuple(filter(f, 'abc'))zany(filter(f, 'abc'))zall(filter(f, 'abc'))zsum(filter(f, 'abc'))zsorted(filter(f, 'abc'))z"sorted(filter(f, 'abc'), key=blah)z%sorted(filter(f, 'abc'), key=blah)[0]zenumerate(filter(f, 'abc'))z$enumerate(filter(f, 'abc'), start=1)zfor i in filter(f, 'abc'): passz[x for x in filter(f, 'abc')]z(x for x in filter(f, 'abc'))r2   r   rU   s     r   test_filter_nochangez Test_filter.test_filter_nochange  s   *q5q(q(q+q'q-q)q'q'q'q*q4q7q-q6q1q/q/qr   c                     d}|                      |           d}d}|                     ||           d}|                      |           d S )Nz:from future_builtins import spam, filter; filter(f, 'ham')z6from future_builtins import spam; x = filter(f, 'abc')z<from future_builtins import spam; x = list(filter(f, 'abc'))z/from future_builtins import *; filter(f, 'ham')r   r   s      r   test_future_builtinsz Test_filter.test_future_builtins  sT    HqHN

1a=qr   N)	rL   r=   rM   r   r   r  r  r  r  r;   r   r   r  r  s  se        E    .  $& & &P	 	 	 	 	r   r  c                   L     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Z xZS )
Test_mapr  c                     |                      d|z   |           t          t          |                               ||           d S )Nz!from future_builtins import map; )r/   r  r  r)   r   rT   rU   r<   s      r   r)   zTest_map.check  C    :Q>BBBh##Aq)))))r   c                 :    d}d}|                      ||           d S )Nzx =    map(   f,    'abc'   )z#x =    list(map(   f,    'abc'   ))rR   rS   s      r   r   z!Test_map.test_prefix_preservation  s&    /5

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nzx = map(f, 'abc')[0]zx = list(map(f, 'abc'))[0]zx = map(None, l)[0]zx = list(l)[0]zx = map(lambda x:x, l)[0]zx = [x for x in l][0]zx = map(f, 'abc')[0][1]zx = list(map(f, 'abc'))[0][1]rR   rS   s      r   test_map_trailerszTest_map.test_map_trailers  s    &,

1a% 

1a+'

1a)/

1ar   c                 :    d}d}|                      ||           d S )Nzx = map(f, 'abc')   #   fooz!x = list(map(f, 'abc'))   #   foorR   rS   s      r   r  zTest_map.test_trailing_comment  s&    -3

1ar   c                 6    d}|                      |d           d S )Nzx = map(None, a, b, c)z5cannot convert map(None, ...) with multiple argumentsrW  r   s     r   !test_None_with_multiple_argumentsz*Test_map.test_None_with_multiple_arguments  s0    (Q !2 	3 	3 	3 	3 	3r   c                 @   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d}|                      ||           d
}d}|                     ||d           d S )Nzx = map(f, 'abc')zx = list(map(f, 'abc'))zx = len(map(f, 'abc', 'def'))z#x = len(list(map(f, 'abc', 'def')))zx = map(None, 'abc')zx = list('abc')z x = map(lambda x: x+1, range(4))zx = [x+1 for x in range(4)]z"x = map(lambda (x): x+1, range(4))zG
            foo()
            # foo
            map(f, x)
            zM
            foo()
            # foo
            list(map(f, x))
            zYou should use a for loop here)r)   r0   rS   s      r   test_map_basiczTest_map.test_map_basic  s    #)

1a/5

1a&!

1a2-

1a 5-

1a

 	

1a9:::::r   c                 p   d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d	}|                      |           d
}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzb.join(map(f, 'abc'))z (a + foo(5)).join(map(f, 'abc'))ziter(map(f, 'abc'))zlist(map(f, 'abc'))zlist(map(f, 'abc'))[0]zset(map(f, 'abc'))zset(map(f, 'abc')).pop()ztuple(map(f, 'abc'))zany(map(f, 'abc'))zall(map(f, 'abc'))zsum(map(f, 'abc'))zsorted(map(f, 'abc'))zsorted(map(f, 'abc'), key=blah)z"sorted(map(f, 'abc'), key=blah)[0]zenumerate(map(f, 'abc'))z!enumerate(map(f, 'abc'), start=1)zfor i in map(f, 'abc'): passz[x for x in map(f, 'abc')]z(x for x in map(f, 'abc'))r2   r  s     r   test_map_nochangezTest_map.test_map_nochange$  s   'q2q%q%q(q$q*q&q$q$q$q'q1q4q*q3q.q,q,qr   c                     d}|                      |           d}d}|                     ||           d}|                      |           d S )Nz:from future_builtins import spam, map, eggs; map(f, 'ham')z9from future_builtins import spam, eggs; x = map(f, 'abc')z?from future_builtins import spam, eggs; x = list(map(f, 'abc'))z,from future_builtins import *; map(f, 'ham')r   r   s      r   r  zTest_map.test_future_builtinsL  sT    HqKQ

1a:qr   )rL   r=   rM   r   r)   r   r  r  r  r  r  r  r  r  s   @r   r  r    s        E* * * * *  
  "  
3 3 3
 ;  ;  ;D& & &P	 	 	 	 	 	 	r   r  c                   :     e Zd ZdZ fdZd Zd Zd Zd Z xZ	S )Test_zipzipc                     |                      d|z   |           t          t          |                               ||           d S )Nz!from future_builtins import zip; )r/   r  r  r)   r  s      r   r)   zTest_zip.checkZ  r  r   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nz	x = zip()zx = list(zip())zx = zip(a, b, c)zx = list(zip(a, b, c))zx = len(zip(a, b))zx = len(list(zip(a, b)))rR   rS   s      r   test_zip_basiczTest_zip.test_zip_basic^  sb    !

1a"(

1a$*

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzx = zip(a, b, c)[0]zx = list(zip(a, b, c))[0]zx = zip(a, b, c)[0][1]zx = list(zip(a, b, c))[0][1]rR   rS   s      r   test_zip_trailerszTest_zip.test_zip_trailersk  sD    %+

1a(.

1ar   c                 p   d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d	}|                      |           d
}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzb.join(zip(a, b))z(a + foo(5)).join(zip(a, b))ziter(zip(a, b))zlist(zip(a, b))zlist(zip(a, b))[0]zset(zip(a, b))zset(zip(a, b)).pop()ztuple(zip(a, b))zany(zip(a, b))zall(zip(a, b))zsum(zip(a, b))zsorted(zip(a, b))zsorted(zip(a, b), key=blah)zsorted(zip(a, b), key=blah)[0]zenumerate(zip(a, b))zenumerate(zip(a, b), start=1)zfor i in zip(a, b): passz[x for x in zip(a, b)]z(x for x in zip(a, b))r2   r  s     r   test_zip_nochangezTest_zip.test_zip_nochanget  s   #q.q!q!q$q q&q"q q q q#q-q0q&q/q*q(q(qr   c                     d}|                      |           d}d}|                     ||           d}|                      |           d S )Nz6from future_builtins import spam, zip, eggs; zip(a, b)z5from future_builtins import spam, eggs; x = zip(a, b)z;from future_builtins import spam, eggs; x = list(zip(a, b))z(from future_builtins import *; zip(a, b)r   r   s      r   r  zTest_zip.test_future_builtins  sT    DqGM

1a6qr   )
rL   r=   rM   r   r)   r  r  r  r  r  r  s   @r   r  r  W  sz        E* * * * *    & & &P	 	 	 	 	 	 	r   r  c                       e Zd ZdZd ZdS )Test_standarderrorstandarderrorc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzx =    StandardError()zx =    Exception()zx = StandardError(a, b, c)zx = Exception(a, b, c)zf(2 + StandardError(a, b, c))zf(2 + Exception(a, b, c))rR   rS   s      r   r   zTest_standarderror.test  sb    ($

1a,(

1a/+

1ar   N)rL   r=   rM   r   r   r;   r   r   r  r    s(        E    r   r  c                       e Zd ZdZd ZdS )
Test_typestypesc                 r   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d}|                      ||           d
}d}|                      ||           d}d}|                      ||           d S )Nztypes.StringTypebytesztypes.DictTyper  ztypes . IntTypeintztypes.ListTyperw  ztypes.LongTypeztypes.NoneTypez
type(None)ztypes.StringTypesz(str,)rR   rS   s      r   test_basic_types_convertz#Test_types.test_basic_types_convert  s    "

1a 

1a!

1a 

1a 

1a 

1a

1ar   N)rL   r=   rM   r   r  r;   r   r   r  r    s(        E    r   r  c                   ~    e 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S )Test_idiomsidiomsc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzwhile 1: foo()zwhile True: foo()zwhile   1: foo()zwhile   True: foo()z8
            while 1:
                foo()
            z;
            while True:
                foo()
            rR   rS   s      r   
test_whilezTest_idioms.test_while  sh     #

1a"%

1a 	

1ar   c                     d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzwhile 11: foo()zwhile 0: foo()zwhile foo(): foo()zwhile []: foo()r2   r   s     r   test_while_unchangedz Test_idioms.test_while_unchanged  sd    !q q$q!qr   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x) == Tisinstance(x, T)zif   type(x) == T: passif   isinstance(x, T): passrR   rS   s      r   test_eq_simplezTest_idioms.test_eq_simple  D    "

1a)-

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzT == type(x)r  zif   T == type(x): passr  rR   rS   s      r   test_eq_reversezTest_idioms.test_eq_reverse  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x+y) == d.get('T')isinstance(x+y, d.get('T'))ztype(   x  +  y) == d.get('T')isinstance(x  +  y, d.get('T'))rR   rS   s      r   test_eq_expressionzTest_idioms.test_eq_expression  D    )-

1a01

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x) is Tr  zif   type(x) is T: passr  rR   rS   s      r   test_is_simplezTest_idioms.test_is_simple  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzT is type(x)r  zif   T is type(x): passr  rR   rS   s      r   test_is_reversezTest_idioms.test_is_reverse  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x+y) is d.get('T')r  ztype(   x  +  y) is d.get('T')r  rR   rS   s      r   test_is_expressionzTest_idioms.test_is_expression'  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x) is not Tnot isinstance(x, T)zif   type(x) is not T: passif   not isinstance(x, T): passrR   rS   s      r   test_is_not_simplezTest_idioms.test_is_not_simple0  D    "&

1a-1

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzT is not type(x)r  zif   T is not type(x): passr  rR   rS   s      r   test_is_not_reversezTest_idioms.test_is_not_reverse9  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x+y) is not d.get('T')not isinstance(x+y, d.get('T'))z"type(   x  +  y) is not d.get('T')#not isinstance(x  +  y, d.get('T'))rR   rS   s      r   test_is_not_expressionz"Test_idioms.test_is_not_expressionB  sD    -1

1a45

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x) != Tr  zif   type(x) != T: passr  rR   rS   s      r   test_ne_simplezTest_idioms.test_ne_simpleK  D    &

1a)1

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzT != type(x)r  zif   T != type(x): passr  rR   rS   s      r   test_ne_reversezTest_idioms.test_ne_reverseT  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nztype(x+y) != d.get('T')r  ztype(   x  +  y) != d.get('T')r  rR   rS   s      r   test_ne_expressionzTest_idioms.test_ne_expression]  sD    )1

1a05

1ar   c                 4    d}|                      |           d S )Nztype(x).__name__r2   r  s     r   test_type_unchangedzTest_idioms.test_type_unchangedf  r   r   c                    d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )NzM
            v = list(t)
            v.sort()
            foo(v)
            :
            v = sorted(t)
            foo(v)
            zV
            v = list(foo(b) + d)
            v.sort()
            foo(v)
            C
            v = sorted(foo(b) + d)
            foo(v)
            zn
            while x:
                v = list(t)
                v.sort()
                foo(v)
            W
            while x:
                v = sorted(t)
                foo(v)
            z_
            v = list(t)
            # foo
            v.sort()
            foo(v)
            L
            v = sorted(t)
            # foo
            foo(v)
            zP
            v = list(   t)
            v.sort()
            foo(v)
            z=
            v = sorted(   t)
            foo(v)
            zl
            try:
                m = list(s)
                m.sort()
            except: pass
            zU
            try:
                m = sorted(s)
            except: pass
            z
            try:
                m = list(s)
                # foo
                m.sort()
            except: pass
            zk
            try:
                m = sorted(s)
                # foo
            except: pass
            zI
            m = list(s)
            # more comments
            m.sort()z6
            m = sorted(s)
            # more commentsrR   rS   s      r   test_sort_list_callzTest_idioms.test_sort_list_callj  s(   
 	

1a
 	

1a
 	

1a
 	

1a
 	

1a
 	

1a 	

1a
 	

1ar   c                 r   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )NzG
            v = t
            v.sort()
            foo(v)
            r  zL
            v = foo(b)
            v.sort()
            foo(v)
            z?
            v = sorted(foo(b))
            foo(v)
            zN
            v = b.keys()
            v.sort()
            foo(v)
            zA
            v = sorted(b.keys())
            foo(v)
            zP
            v = foo(b) + d
            v.sort()
            foo(v)
            r  zh
            while x:
                v = t
                v.sort()
                foo(v)
            r  zY
            v = t
            # foo
            v.sort()
            foo(v)
            r  zI
            v =   t
            v.sort()
            foo(v)
            z<
            v =   sorted(t)
            foo(v)
            rR   rS   s      r   test_sort_simple_exprz!Test_idioms.test_sort_simple_expr  s   
 	

1a
 	

1a
 	

1a
 	

1a
 	

1a
 	

1a
 	

1ar   c                 b    d}|                      |           d}|                      |           d S )NzM
            v = list(t)
            w.sort()
            foo(w)
            zN
            v = list(t)
            v.sort(u)
            foo(v)
            r2   r   s     r   test_sort_unchangedzTest_idioms.test_sort_unchanged   s>    
 	q
 	qr   N)rL   r=   rM   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r;   r   r   r  r    s/       E  &                            b b bHP P Pd    r   r  c                       e Zd ZdZd ZdS )Test_basestring
basestringc                 :    d}d}|                      ||           d S )Nzisinstance(x, basestring)zisinstance(x, str)rR   rS   s      r   test_basestringzTest_basestring.test_basestring2  s&    +$

1ar   N)rL   r=   rM   r   r  r;   r   r   r  r  /  s(        E    r   r  c                       e Zd ZdZd Zd ZdS )Test_bufferbufferc                 :    d}d}|                      ||           d S )Nzx = buffer(y)zx = memoryview(y)rR   rS   s      r   test_bufferzTest_buffer.test_buffer:  r  r   c                 :    d}d}|                      ||           d S )Nzbuffer(y)[4:5]zmemoryview(y)[4:5]rR   rS   s      r   test_slicingzTest_buffer.test_slicing?  r;  r   N)rL   r=   rM   r   r  r  r;   r   r   r
  r
  7  s7        E  
    r   r
  c                       e Zd ZdZd Zd ZdS )Test_futurefuturec                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzfrom __future__ import bracesr+   z'# comment
from __future__ import bracesz
# comment
z'from __future__ import braces
# commentz

# commentrR   rS   s      r   test_futurezTest_future.test_futureG  sb    /

1a:

1a:

1ar   c                 0    |                      d           d S )Nr   rK   r  s    r   test_run_orderzTest_future.test_run_orderT  s    w'''''r   N)rL   r=   rM   r   r  r  r;   r   r   r  r  D  s7        E  ( ( ( ( (r   r  c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )Test_itertools	itertoolsc                 f    dD ]-}dD ](}||dz   |z   z  }||z  }|                      ||           ).d S )N)z
itertools.r+   )r  r  r  irR   )r   r!   r"   r  r  rT   rU   s          r   checkallzTest_itertools.checkallZ  sc     $ 	! 	!A- ! !QsU1W%AJ

1a    !	! 	!r   c                 :    d}d}|                      ||           d S )Nzitertools.izip(a, b)z	zip(a, b)rR   rS   s      r   test_0zTest_itertools.test_0d  s(     #

1ar   c                 :    d}d}|                      ||           d S )Nz%s(f, a)r  rS   s      r   r`   zTest_itertools.test_1k  s&    ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzitertools.ifilterfalse(a, b)zitertools.filterfalse(a, b)zitertools.izip_longest(a, b)zitertools.zip_longest(a, b)rR   rS   s      r   test_qualifiedzTest_itertools.test_qualifiedp  sD    .-

1a.-

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzifilterfalse(a, b)zfilterfalse(a, b)zizip_longest(a, b)zzip_longest(a, b)rR   rS   s      r   rb   zTest_itertools.test_2y  sD    $#

1a$#

1ar   c                 :    d}d}|                      ||           d S )Nz    %s(f, a)r!  rS   s      r   r   zTest_itertools.test_space_1  s&    ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nz     itertools.ifilterfalse(a, b)z    itertools.filterfalse(a, b)z     itertools.izip_longest(a, b)z    itertools.zip_longest(a, b)rR   rS   s      r   r   zTest_itertools.test_space_2  sD    21

1a21

1ar   c                 4    |                      ddd           d S )Nr  r  r  r  r  s    r   r  zTest_itertools.test_run_order  s     ueX66666r   N)rL   r=   rM   r   r  r  r`   r#  rb   r   r   r  r;   r   r   r  r  W  s        E! ! !    
      
  7 7 7 7 7r   r  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
Test_itertools_importsitertools_importsc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nz%from itertools import imap, izip, foofrom itertools import fooz*from itertools import bar, imap, izip, foozfrom itertools import bar, fooz'from itertools import chain, imap, izipzfrom itertools import chainrR   rS   s      r   test_reducedz#Test_itertools_imports.test_reduced  sb    3'

1a8,

1a5)

1ar   c                 :    d}d}|                      ||           d S )Nz%#foo
from itertools import imap, izipz#foo
rR   rS   s      r   test_commentsz$Test_itertools_imports.test_comments  s&    4

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nz from itertools import imap, izipr+   zfrom itertools import iziprR   rS   s      r   	test_nonez Test_itertools_imports.test_none  sD    .

1a(

1ar   c                    d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}|                     |           d S )Nz-from itertools import izip, bar as bang, imapz!from itertools import bar as bangz-from itertools import izip as _zip, imap, barzfrom itertools import barz"from itertools import imap as _mapr+   z0from itertools import imap as _map, izip as _zip)r)   r/   )r   rT   rU   r   s       r   test_import_asz%Test_itertools_imports.test_import_as  s    ;/

1a;'

1a0

1a>

1a/qr   c                     dD ]f}d|}d|}|                      ||           d|d}d|d}|                      ||           d|d}d|d}|                      ||           gd S )N)filterfalsezip_longestzfrom itertools import izfrom itertools import zfrom itertools import imap, iz, foozfrom itertools import bar, izfrom itertools import bar, rR   )r   r/  rT   rU   s       r   test_ifilter_and_zip_longestz3Test_itertools_imports.test_ifilter_and_zip_longest  s    0 	 	DD/3t5AA.2d4AJJq!:>$$@AA37449AJJq!9=?AA8<>AJJq!	 	r   c                 4    d}|                      |           d S )Nzfrom itertools import *r2   r   s     r   test_import_starz'Test_itertools_imports.test_import_star      %qr   c                 4    d}|                      |           d S )Nr,  r2   r   s     r   r   z%Test_itertools_imports.test_unchanged  s    'qr   N)rL   r=   rM   r   r-  r/  r1  r3  r7  r9  r   r;   r   r   r)  r)    s        E    
    (    
    r   r)  c                        e Zd ZdZ fdZd Z f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 xZS )Test_importr|  c                      t          t                                                      g  _        t	                       _        d _         fd}ddlm} ||_	        d S )NTc                 X    j                             |            j        p| j        v S r   )files_checkedr  always_existspresent_files)r/  r   s    r   fake_existsz&Test_import.setUp.<locals>.fake_exists  s0    %%d+++%E$$2D*DEr   r   
fix_import)
r  r=  r   r@  setrB  rA  lib2to3.fixesrE  exists)r   rC  rE  r<   s   `  r   r   zTest_import.setUp  s~    k4  &&(((   UU!	F 	F 	F 	F 	F 	-,,,,,'
r   c                 >    ddl m} t          j        j        |_        d S )Nr   rD  )rG  rE  ospathrH  )r   rE  s     r   tearDownzTest_import.tearDown  s&    ,,,,,,GN
r   c                     d| _         t          t          |                               ||           d| _         t          t          |                               |           d S )NTF)rA  r  r=  r)   r/   r  s      r   
check_bothzTest_import.check_both  sW    !k4  &&q!,,,"k4  **1-----r   c                 *   d }d| _         t          dg          | _        dt          j        j        ddddf} |d	          d
 |d          f}|D ]g | _        | _        |                     d           t          j        	                              r#t          j        	                              dz   ndt          fd|D                       }|
                    d           |                     t          | j                  |           d S )Nc                 p    t           j        j                            |                     d                    S )N/)rJ  rK  pathsepr-   split)rK  s    r   pz)Test_import.test_files_checked.<locals>.p  s$    7?''

3888r   F__init__.pyz.pyz.pycz.soz.slz.pydz/spam/eggs.pyzni.pyz../../shrubbery.pyz
import jamz/jamjamc              3   "   K   | ]	}|z   V  
d S r   r;   )r>   extr/  s     r   	<genexpr>z1Test_import.test_files_checked.<locals>.<genexpr>  s'      !L!L$*!L!L!L!L!L!Lr   )rA  rF  rB  rJ  rK  sepr@  r   r/   dirnameaddr   )r   rT  expected_extensionsnames_to_testexpected_checksr/  s        @r   test_files_checkedzTest_import.test_files_checked  s4   	9 	9 	9 # -11$bgk65%P?++Waa8L6M6MN! 	G 	GD!#D DMNN<(((wt$$ wt,,v5!!L!L!L!L8K!L!L!LLLO...S!344oFFFF	G 	Gr   c                 l    d}d| _         t          dg          | _        |                     |           d S )N
import barFbar.pyrA  rF  rB  r/   r   s     r   test_not_in_packagezTest_import.test_not_in_package  s7    " (__qr   c                 n    d}d| _         t          ddg          | _        |                     |           d S )Nz1from __future__ import absolute_import
import barFrU  rc  rd  r   s     r   !test_with_absolute_import_enabledz-Test_import.test_with_absolute_import_enabled  s<    @" -!:;;qr   c                 t    d}d}d| _         t          ddg          | _        |                     ||           d S )Nrb  from . import barFrU  rc  )rA  rF  rB  r)   rS   s      r   test_in_packagezTest_import.test_in_package  sC    " -!:;;

1ar   c                     d}d}d| _         t          ddt          j        j        z   g          | _        |                     ||           d S )Nrb  ri  FrU  bar)rA  rF  rJ  rK  rZ  rB  r)   rS   s      r   test_import_from_packagez$Test_import.test_import_from_package$  sL    " -1D!EFF

1ar   c                 4    d}|                      |           d S )Nri  r2   r   s     r   test_already_relative_importz(Test_import.test_already_relative_import+  s    qr   c                 :    d}d}|                      ||           d S )Nzimport bar # Foozfrom . import bar # FoorR   rS   s      r   test_comments_and_indentz$Test_import.test_comments_and_indent/  s&    %

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzfrom foo import bar, bazzfrom .foo import bar, bazzfrom foo import barzfrom .foo import barzfrom foo import (bar, baz)zfrom .foo import (bar, baz)rN  rS   s      r   	test_fromzTest_import.test_from4  sb    &'1!"1()1r   c                 :    d}d}|                      ||           d S )Nzfrom green.eggs import hamzfrom .green.eggs import hamrs  rS   s      r   test_dotted_fromzTest_import.test_dotted_fromA  s&    ()1r   c                 :    d}d}|                      ||           d S )Nz"from green.eggs import ham as spamz#from .green.eggs import ham as spamrs  rS   s      r   test_from_aszTest_import.test_from_asF  s&    011r   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nz
import foozfrom . import fooimport foo, barzfrom . import foo, barzimport foo, bar, xzfrom . import foo, bar, xzimport x, y, zzfrom . import x, y, zrs  rS   s      r   test_importzTest_import.test_importK  s    1$1 '1#1r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzimport foo as xzfrom . import foo as xzimport a as b, b as c, c as dz$from . import a as b, b as c, c as drs  rS   s      r   r3  zTest_import.test_import_as\  sD    $1+21r   c                 p    d| _         t          ddg          | _        d}|                     |d           d S )NFzfoo.pyrU  rz  z#absolute and local imports together)rA  rF  rB  r4   r   s     r   test_local_and_absolutez#Test_import.test_local_and_absolutee  sA    " (M!:;;Q EFFFFFr   c                 :    d}d}|                      ||           d S )Nzimport foo.barzfrom . import foo.barrs  rS   s      r   test_dotted_importzTest_import.test_dotted_importl  s&    #1r   c                 :    d}d}|                      ||           d S )Nzimport foo.bar as bangzfrom . import foo.bar as bangrs  rS   s      r   test_dotted_import_asz!Test_import.test_dotted_import_asq  s&    $+1r   c                 :    d}d}|                      ||           d S )Nz1
        # prefix
        import foo.bar
        z8
        # prefix
        from . import foo.bar
        rs  rS   s      r   test_prefixzTest_import.test_prefixv  s,     	1r   )rL   r=   rM   r   r   rL  rN  r`  re  rg  rj  rm  ro  rq  rt  rv  rx  r{  r3  r~  r  r  r  r  r  s   @r   r=  r=    s[       E( ( ( ( (+ + +. . . . .G G G0            
    
  
  "  G G G  
  
	 	 	 	 	 	 	r   r=  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )Test_set_literalset_literalc                    d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}|                      ||           d}d}|                      ||           d	}|                      ||           d
}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzset([1, 2, 3])z	{1, 2, 3}zset((1, 2, 3))z	set((1,)){1}zset([1])zset((a, b))z{a, b}zset([a, b])zset((a*234, f(args=23)))z{a*234, f(args=23)}zset([a*23, f(23)])z{a*23, f(23)}zset([a-234**23])z{a-234**23}rR   rS   s      r   rV   zTest_set_literal.test_basic  s    

1a 

1a

1a

1a

1a

1a*%

1a$

1a"

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nzset([x for x in y])z{x for x in y}zset([x for x in y if x == m])z{x for x in y if x == m}zset([x for x in y for a in b])z{x for x in y for a in b}zset([f(x) - 23 for x in y])z{f(x) - 23 for x in y}rR   rS   s      r   test_listcompszTest_set_literal.test_listcomps  s    % 

1a/*

1a0+

1a-(

1ar   c                 r   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzset( [1, 2])z{1, 2}zset([1 ,  2])z{1 ,  2}z
set([ 1 ])z{ 1 }z
set( [1] )r  zset([  1,  2  ])z{  1,  2  }zset([x  for x in y ])z{x  for x in y }z<set(
                   [1, 2]
               )
            z{1, 2}
rR   rS   s      r   r  z Test_set_literal.test_whitespace  s    

1a

1a

1a

1a"

1a'"

1a 

1ar   c                 n    d}d}|                      ||           d}d}|                      ||           d S )Nzset((1, 2)) # Hiz{1, 2} # HizZ
            # Foo
            set( # Bar
               (1, 2)
            )
            z2
            # Foo
            {1, 2}
            rR   rS   s      r   r/  zTest_set_literal.test_comments  sJ    "

1a 	

1ar   c                    d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d}|                      |           d S )Nzset()zset(a)zset(a, b, c)zset(x for x in y)zset(x for x in y if z)zset(a*823-23**2 + f(23))r2   r   s     r   r   zTest_set_literal.test_unchanged  s    qqq $q(q*qr   N)	rL   r=   rM   r   rV   r  r  r/  r   r;   r   r   r  r    sf        E! ! !F  "  @  $    r   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	Test_sys_excsys_excc                 :    d}d}|                      ||           d S )Nzsys.exc_typezsys.exc_info()[0]rR   rS   s      r   r  zTest_sys_exc.test_0  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzsys.exc_valuezsys.exc_info()[1]rR   rS   s      r   r`   zTest_sys_exc.test_1	  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzsys.exc_tracebackzsys.exc_info()[2]rR   rS   s      r   rb   zTest_sys_exc.test_2  s&    

1ar   c                 :    d}d}|                      ||           d S )Nzsys.exc_type # Foozsys.exc_info()[0] # FoorR   rS   s      r   re   zTest_sys_exc.test_3  s&     %

1ar   c                 :    d}d}|                      ||           d S )Nzsys.  exc_typezsys.  exc_info()[0]rR   rS   s      r   rg   zTest_sys_exc.test_4  &    !

1ar   c                 :    d}d}|                      ||           d S )Nzsys  .exc_typezsys  .exc_info()[0]rR   rS   s      r   ri   zTest_sys_exc.test_5  r  r   N)
rL   r=   rM   r   r  r`   rb   re   rg   ri   r;   r   r   r  r    ss        E  
  
  
  
  
    r   r  c                   Z    e 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S )
Test_parenparenc                 :    d}d}|                      ||           d S )Nz[i for i in 1, 2 ]z[i for i in (1, 2) ]rR   rS   s      r   r  zTest_paren.test_0&  s&    $&

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i in 1, 2, ]z[i for i in (1, 2,) ]rR   rS   s      r   r`   zTest_paren.test_1+  s&    %'

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i  in     1, 2 ]z[i for i  in     (1, 2) ]rR   rS   s      r   rb   zTest_paren.test_20  s&    )+

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i in 1, 2 if i]z[i for i in (1, 2) if i]rR   rS   s      r   re   zTest_paren.test_35  s&    (*

1ar   c                 :    d}d}|                      ||           d S )Nz[i for i in 1,    2    ]z[i for i in (1,    2)    ]rR   rS   s      r   rg   zTest_paren.test_4:  s&    *,

1ar   c                 :    d}d}|                      ||           d S )Nz(i for i in 1, 2)(i for i in (1, 2))rR   rS   s      r   ri   zTest_paren.test_5?  s&    #%

1ar   c                 :    d}d}|                      ||           d S )Nz(i for i in 1   ,2   if i)z(i for i in (1   ,2)   if i)rR   rS   s      r   rl   zTest_paren.test_6D  s&    ,.

1ar   c                 4    d}|                      |           d S )Nz[i for i in (1, 2)]r2   r   s     r   test_unchanged_0zTest_paren.test_unchanged_0I  r:  r   c                 4    d}|                      |           d S )Nz[i for i in foo()]r2   r   s     r   r   zTest_paren.test_unchanged_1M  r~  r   c                 4    d}|                      |           d S )Nz[i for i in (1, 2) if nothing]r2   r   s     r   r   zTest_paren.test_unchanged_2Q  r   r   c                 4    d}|                      |           d S )Nr  r2   r   s     r   r   zTest_paren.test_unchanged_3U  r:  r   c                 4    d}|                      |           d S )Nz[i for i in m]r2   r   s     r   r   zTest_paren.test_unchanged_4Y  r  r   N)rL   r=   rM   r   r  r`   rb   re   rg   ri   rl   r  r   r   r   r   r;   r   r   r  r  #  s        E  
  
  
  
  
  
  
            r   r  c                   $    e Zd ZdZd Zd Zd ZdS )Test_metaclass	metaclassc                    |                      d           |                      d           |                      d           |                      d           |                      d           |                      d           |                      d           d}|                      |           d	}|                      |           d S )
Nzclass X(): passzclass X(object): passzclass X(object1, object2): passz(class X(object1, object2, object3): passzclass X(metaclass=Meta): passz'class X(b, arg=23, metclass=Meta): passz2class X(b, arg=23, metaclass=Meta, other=42): passzD
        class X:
            def __metaclass__(self): pass
        z1
        class X:
            a[23] = 74
        r2   r   s     r   r   zTest_metaclass.test_unchangeda  s    ())).///8999ABBB6777@AAAKLLL 	q 	qr   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzQ
        class X:
            # hi
            __metaclass__ = AppleMeta
        zQ
        class X(metaclass=AppleMeta):
            # hi
            pass
        zR
        class X:
            __metaclass__ = Meta
            # Bedtime!
        zR
        class X(metaclass=Meta):
            pass
            # Bedtime!
        rR   rS   s      r   r/  zTest_metaclass.test_commentsv  sP    

 	

1a

 	

1ar   c                 B   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d}|                      ||           d
}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )NzK
        class X():
            __metaclass__ = Q
            pass
        z8
        class X(metaclass=Q):
            pass
        z"class X(object): __metaclass__ = Qz"class X(object, metaclass=Q): passzW
        class X(object):
            __metaclass__ = Meta
            bar = 7
        zF
        class X(object, metaclass=Meta):
            bar = 7
        zJ
        class X:
            __metaclass__ = Meta; x = 4; g = 23
        zD
        class X(metaclass=Meta):
            x = 4; g = 23
        zW
        class X(object):
            bar = 7
            __metaclass__ = Meta
        zl
        class X():
            __metaclass__ = A
            __metaclass__ = B
            bar = 7
        z;
        class X(metaclass=B):
            bar = 7
        z[
        class X(clsA, clsB):
            __metaclass__ = Meta
            bar = 7
        zJ
        class X(clsA, clsB, metaclass=Meta):
            bar = 7
        z(class m(a, arg=23): __metaclass__ = Metaz(class m(a, arg=23, metaclass=Meta): passzN
        class X(expression(2 + 4)):
            __metaclass__ = Meta
        zN
        class X(expression(2 + 4), metaclass=Meta):
            pass
        zT
        class X(expression(2 + 4), x**4):
            __metaclass__ = Meta
        zT
        class X(expression(2 + 4), x**4, metaclass=Meta):
            pass
        zT
        class X:
            __metaclass__ = Meta
            save.py = 23
        zC
        class X(metaclass=Meta):
            save.py = 23
        rR   rS   s      r   	test_metazTest_metaclass.test_meta  s   
 	

1a 54

1a
 	

1a 	

1a
 	

1a 	

1a
 	

1a ;:

1a 	

1a 	

1a
 	

1ar   N)rL   r=   rM   r   r   r/  r  r;   r   r   r  r  ]  sK        E  *  2p p p p pr   r  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )Test_getcwdugetcwduc                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )	Nz
os.getcwduz	os.getcwdzos.getcwdu()os.getcwd()zmeth = os.getcwduzmeth = os.getcwdzos.getcwdu(args)zos.getcwd(args)rR   rS   s      r   rV   zTest_getcwdu.test_basic  s    

1a

1a#"

1a"!

1ar   c                 :    d}d}|                      ||           d S )Nzos.getcwdu() # Foozos.getcwd() # FoorR   rS   s      r   r   zTest_getcwdu.test_comment  r  r   c                     d}|                      |           d}|                      |           d}|                      |           d S )Nr  z	getcwdu()zos.getcwdb()r2   r   s     r   r   zTest_getcwdu.test_unchanged  sM    qqqr   c                 :    d}d}|                      ||           d S )Nz<
            if 1:
                os.getcwdu()
            z;
            if 1:
                os.getcwd()
            rR   rS   s      r   test_indentationzTest_getcwdu.test_indentation&  rj  r   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzos .getcwdu()zos .getcwd()zos.  getcwduzos.  getcwdzos.getcwdu (  )zos.getcwd (  )rR   rS   s      r   test_multilationzTest_getcwdu.test_multilation1  sb    

1a

1a! 

1ar   N)	rL   r=   rM   r   rV   r   r   r  r  r;   r   r   r  r    sd        E  "  
  	 	 	    r   r  c                   f    e 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S )Test_operatoroperatorc                 :    d}d}|                      ||           d S )Nzoperator.isCallable(x)zcallable(x)rR   rS   s      r   test_operator_isCallablez&Test_operator.test_operator_isCallableC  s&    $

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzoperator.sequenceIncludes(x, y)zoperator.contains(x, y)z operator .sequenceIncludes(x, y)zoperator .contains(x, y)z!operator.  sequenceIncludes(x, y)zoperator.  contains(x, y)rR   rS   s      r   test_operator_sequenceIncludesz,Test_operator.test_operator_sequenceIncludesH  sb    -%

1a.&

1a/'

1ar   c                 :    d}d}|                      ||           d S )Nzoperator.isSequenceType(x)z>import collections.abc
isinstance(x, collections.abc.Sequence)rR   rS   s      r   test_operator_isSequenceTypez*Test_operator.test_operator_isSequenceTypeU  s&    (M

1ar   c                 :    d}d}|                      ||           d S )Nzoperator.isMappingType(x)z=import collections.abc
isinstance(x, collections.abc.Mapping)rR   rS   s      r   test_operator_isMappingTypez)Test_operator.test_operator_isMappingTypeZ  s&    'L

1ar   c                 :    d}d}|                      ||           d S )Nzoperator.isNumberType(x)z,import numbers
isinstance(x, numbers.Number)rR   rS   s      r   test_operator_isNumberTypez(Test_operator.test_operator_isNumberType_  s&    &;

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzoperator.repeat(x, n)zoperator.mul(x, n)zoperator .repeat(x, n)zoperator .mul(x, n)zoperator.  repeat(x, n)zoperator.  mul(x, n)rR   rS   s      r   test_operator_repeatz"Test_operator.test_operator_repeatd  sb    # 

1a$!

1a%"

1ar   c                     d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzoperator.irepeat(x, n)zoperator.imul(x, n)zoperator .irepeat(x, n)zoperator .imul(x, n)zoperator.  irepeat(x, n)zoperator.  imul(x, n)rR   rS   s      r   test_operator_irepeatz#Test_operator.test_operator_irepeatq  sb    $!

1a%"

1a&#

1ar   c                 :    d}d}|                      ||           d S )NzisCallable(x)z"You should use 'callable(x)' here.rW  r   r   ts      r   test_bare_isCallablez"Test_operator.test_bare_isCallable~  s(    0Q"""""r   c                 :    d}d}|                      ||           d S )NzsequenceIncludes(x, y)z.You should use 'operator.contains(x, y)' here.rW  r  s      r   test_bare_sequenceIncludesz(Test_operator.test_bare_sequenceIncludes  s(    $<Q"""""r   c                 :    d}d}|                      ||           d S )NzisSequenceType(z)z>You should use 'isinstance(z, collections.abc.Sequence)' here.rW  r  s      r   !test_bare_operator_isSequenceTypez/Test_operator.test_bare_operator_isSequenceType  s(    LQ"""""r   c                 :    d}d}|                      ||           d S )NzisMappingType(x)z=You should use 'isinstance(x, collections.abc.Mapping)' here.rW  r  s      r    test_bare_operator_isMappingTypez.Test_operator.test_bare_operator_isMappingType  s(    KQ"""""r   c                 :    d}d}|                      ||           d S )NzisNumberType(y)z4You should use 'isinstance(y, numbers.Number)' here.rW  r  s      r   test_bare_operator_isNumberTypez-Test_operator.test_bare_operator_isNumberType  s(    BQ"""""r   c                 :    d}d}|                      ||           d S )Nzrepeat(x, n)z)You should use 'operator.mul(x, n)' here.rW  r  s      r   test_bare_operator_repeatz'Test_operator.test_bare_operator_repeat  s(    7Q"""""r   c                 :    d}d}|                      ||           d S )Nzirepeat(y, 187)z,You should use 'operator.imul(y, 187)' here.rW  r  s      r   test_bare_operator_irepeatz(Test_operator.test_bare_operator_irepeat  s(    :Q"""""r   N)rL   r=   rM   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r;   r   r   r  r  ?  s        E  
    
  
  
    # # #
# # #
# # #
# # #
# # #
# # #
# # # # #r   r  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
Test_exitfuncexitfuncc                 :    d}d}|                      ||           d S )NzI
            import sys
            sys.exitfunc = my_atexit
            ze
            import sys
            import atexit
            atexit.register(my_atexit)
            rR   rS   s      r   r&  zTest_exitfunc.test_simple  ,    
 	

1ar   c                 :    d}d}|                      ||           d S )NzO
            import sys, crumbs
            sys.exitfunc = my_func
            zY
            import sys, crumbs, atexit
            atexit.register(my_func)
            rR   rS   s      r   test_names_importzTest_exitfunc.test_names_import  rj  r   c                 :    d}d}|                      ||           d S )Nzh
            import sys
            sys.exitfunc = do(d)/a()+complex(f=23, g=23)*expression
            z
            import sys
            import atexit
            atexit.register(do(d)/a()+complex(f=23, g=23)*expression)
            rR   rS   s      r   test_complex_expressionz%Test_exitfunc.test_complex_expression  r  r   c                 n    d}d}|                      ||           d}d}|                      ||           d S )NzN
            import sys # Foo
            sys.exitfunc = f # Blah
            zj
            import sys
            import atexit # Foo
            atexit.register(f) # Blah
            zo
            import apples, sys, crumbs, larry # Pleasant comments
            sys.exitfunc = func
            zy
            import apples, sys, crumbs, larry, atexit # Pleasant comments
            atexit.register(func)
            rR   rS   s      r   r/  zTest_exitfunc.test_comments  sP    
 	

1a 	

1ar   c                 :    d}d}|                      ||           d S )Nz]
            import sys
            def f():
                sys.exitfunc = func
            zz
            import sys
            import atexit
            def f():
                atexit.register(func)
             rR   rS   s      r   test_in_a_functionz Test_exitfunc.test_in_a_function  s,    
 	

1ar   c                 @    d}d}d}|                      |||           d S )Nzsys.exitfunc = fzatexit.register(f)zKCan't find sys import; Please add an atexit import at the top of your file.r3   )r   rT   rU   msgs       r   test_no_sys_importz Test_exitfunc.test_no_sys_import  s/    "$ 

1ar   c                 4    d}|                      |           d S )Nzf(sys.exitfunc)r2   r   s     r   r   zTest_exitfunc.test_unchanged  r   r   N)rL   r=   rM   r   r&  r  r  r/  r  r  r   r;   r   r   r  r    s        E
 
 
	 	 	
 
 
  ,        r   r  c                   $    e Zd ZdZd Zd Zd ZdS )Test_assertsassertsc                 J    g d}|D ]\  }}|                      ||           d S )N))zself.assert_(True)self.assertTrue(True))zself.assertEquals(2, 2)self.assertEqual(2, 2))zself.assertNotEquals(2, 3)self.assertNotEqual(2, 3))zself.assertAlmostEquals(2, 3)self.assertAlmostEqual(2, 3))z self.assertNotAlmostEquals(2, 8)self.assertNotAlmostEqual(2, 8))zself.failUnlessEqual(2, 2)r  )zself.failIfEqual(2, 3)r  )z self.failUnlessAlmostEqual(2, 3)r  )zself.failIfAlmostEqual(2, 8)r  )zself.failUnless(True)r  )zself.failUnlessRaises(foo)zself.assertRaises(foo))zself.failIf(False)zself.assertFalse(False)rR   )r   testsrT   rU   s       r   test_deprecated_namesz"Test_asserts.test_deprecated_names  sI    
 
 
  	 	DAqJJq!	 	r   c                 r   d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d}d}|                      ||           d	}d
}|                      ||           d}d}|                      ||           d}d}|                      ||           d S )Nzeq = self.assertEqualszeq = self.assertEqualz#self.assertEquals(2, 3, msg="fail")z"self.assertEqual(2, 3, msg="fail")z)self.assertEquals(2, 3, msg="fail") # fooz(self.assertEqual(2, 3, msg="fail") # foozself.assertEquals (2, 3)zself.assertEqual (2, 3)z  self.assertEquals (2, 3)z  self.assertEqual (2, 3)z0with self.failUnlessRaises(Explosion): explode()z,with self.assertRaises(Explosion): explode()z6with self.failUnlessRaises(Explosion) as cm: explode()z2with self.assertRaises(Explosion) as cm: explode()rR   rS   s      r   test_variantszTest_asserts.test_variants  s    $#

1a10

1a76

1a&%

1a('

1a>:

1aD@

1ar   c                 Z    |                      d           |                      d           d S )Nzself.assertEqualsOnSaturdayz!self.assertEqualsOnSaturday(3, 5)r2   r  s    r   r   zTest_asserts.test_unchanged'  s.    4555:;;;;;r   N)rL   r=   rM   r   r  r  r   r;   r   r   r  r    sF        E  $  .< < < < <r   r  )C__doc__rJ  r  r   r  r   r
   r   r   lib2to3.testsr   TestCaser	   rO   r]   rz   r   r   r   r   r   r  r   rC  ro  r  r  r  r  r  r  r  r+  rA  rH  ra  rm  rq  r  r  r  r  r  rA  rK  rq  r  r  r  r  r  r  r  r  r
  r  r  r)  r=  r  r  r  r  r  r  r  r  r;   r   r   <module>r     sk
   ( ( 
			             ' & & & & & & & ! ! ! ! ! !7N 7N 7N 7N 7NG$ 7N 7N 7Nr    m   68 8 8 8 8= 8 8 8tC C C C C C C CJ9 9 9 9 9- 9 9 9v/ / / / /- / / /b! ! ! ! !- ! ! !Fg g g g g g g gT1 1 1 1 1 1 1 1f$ $ $ $ $ $ $ $LQ Q Q Q Q- Q Q Qf} } } } } } } }~{ { { { { { { {z+ + + + + + + +\# # # # #M # # #L4 4 4 4 4m 4 4 48d d d d d d d dLF7 F7 F7 F7 F7- F7 F7 F7P	 	 	 	 	m 	 	 	- - - - -] - - -^    ]   4( ( ( ( (m ( ( (V_ _ _ _ _ _ _ _D    ="3   *8 8 8 8 8M#4 8 8 8
- - - - -}.? - - - o% o% o% o% o%- o% o% o%d- - - - - - - -^y y y y y y y yv    }   @X X X X X X X Xt2 2 2 2 2= 2 2 2h@ @ @ @ @} @ @ @D, , , , ,= , , ,\L L L L L= L L L^f f f f f- f f fPz z z z z} z z zxN N N N N} N N N`               @V V V V V- V V Vp
    m       -   ( ( ( ( (- ( ( (&:7 :7 :7 :7 :7] :7 :7 :7zG G G G G] G G GTa a a a a- a a aH| | | | |} | | |~    =   D8 8 8 8 8 8 8 8tb b b b b] b b bJ: : : : := : : :z`# `# `# `# `#M `# `# `#FU U U U UM U U Up/< /< /< /< /<= /< /< /< /< /<r   