Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/lib2to3/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/lib2to3/tests/__pycache__/test_fixers.cpython-38.opt-2.pyc
U

?��g��@s�ddlZddlmZddlmZddlmZmZddlm	Z	Gdd�de	j
�ZGdd	�d	e�ZGd
d�de�Z
Gdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)e�ZGd*d+�d+e�ZGd,d-�d-e�ZGd.d/�d/e�ZGd0d1�d1e�Z Gd2d3�d3�Z!Gd4d5�d5ee!�Z"Gd6d7�d7ee!�Z#Gd8d9�d9ee!�Z$Gd:d;�d;e�Z%Gd<d=�d=e�Z&Gd>d?�d?e�Z'Gd@dA�dAe�Z(GdBdC�dCe�Z)GdDdE�dEe�Z*GdFdG�dGe�Z+GdHdI�dIe�Z,GdJdK�dKe�Z-GdLdM�dMe�Z.GdNdO�dOe�Z/GdPdQ�dQe�Z0GdRdS�dSe�Z1GdTdU�dUe�Z2GdVdW�dWe�Z3GdXdY�dYe�Z4GdZd[�d[e�Z5Gd\d]�d]e�Z6Gd^d_�d_e�Z7Gd`da�dae�Z8Gdbdc�dce�Z9Gddde�dee�Z:Gdfdg�dge�Z;Gdhdi�die�Z<Gdjdk�dke�Z=Gdldm�dme�Z>Gdndo�doe�Z?Gdpdq�dqe�Z@Gdrds�dse�ZAdS)t�N)�chain)�
itemgetter)�pygram�
fixer_util)�supportc@sLeZdZddd�Zdd�Zddd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)�
FixerTestCaseN�lib2to3cCsP|dkr|jg}t�|||�|_g|_d|_t|jj|jj�D]}|j|_	q>dS)Nz<string>)
�fixerr�get_refactorer�refactor�	fixer_log�filenamerZ	pre_orderZ
post_order�log)�selfZfix_listZ	fixer_pkg�optionsr	�r�8/opt/cppython/lib/python3.8/lib2to3/tests/test_fixers.py�setUps�zFixerTestCase.setUpcCs8t�|�}t�|�}|j�||j�}|�|t|��|S�N)rZreformatrZrefactor_stringr
�assertEqual�str)r�before�after�treerrr�_checks


zFixerTestCase._checkFcCs.|�||�}|�|j�|s*|�|jg�dSr)r�
assertTrue�was_changedrr)rrr�ignore_warningsrrrr�check#szFixerTestCase.checkcCs4|�||�}|�|d�|j��|s0|�|j�dS)N�)rZassertIn�joinrrr)rrr�message�	unchangedrrrr�warns)szFixerTestCase.warnscCs|j|||dd�dS)NT�r"�r#)rrr!rrr�warns_unchanged/szFixerTestCase.warns_unchangedcCs"|�||�|s|�|jg�dSr)rrr)rrrrrrr"2szFixerTestCase.unchangedcGs�|jg}|�|�t�d|�}|��\}}d|j}|rN|djj�|�rNdS|rl|djj�|�rl|sldS|�dd�	dd�||D��|f�dS)NrZfix_���z5Fixer run order (%s) is incorrect; %s should be last.�, cSsg|]}|jj�qSr)�	__class__�
__module__)�.0�xrrr�
<listcomp>Dsz3FixerTestCase.assert_runs_after.<locals>.<listcomp>)
r	�extendrr
Z
get_fixersr)r*�endswithZfailr )r�names�fixes�r�preZpost�nrrr�assert_runs_after7s

�zFixerTestCase.assert_runs_after)NrN)F)F)F)
�__name__r*�__qualname__rrrr#r&r"r5rrrrr
s



rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_ne�necCsd}d}|�||�dS)Nzif x <> y:
            passzif x != y:
            pass�r�r�b�arrr�
test_basicIszTest_ne.test_basiccCsd}d}|�||�dS)Nzif x<>y:
            passzif x!=y:
            passr:r;rrr�test_no_spacesQszTest_ne.test_no_spacescCsd}d}|�||�dS)Nzif x<>y<>z:
            passzif x!=y!=z:
            passr:r;rrr�test_chainedYszTest_ne.test_chainedN)r6r*r7r	r>r?r@rrrrr8Fsr8c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�Test_has_keyZhas_keycCsd}d}|�||�dS)Nz$x = d.has_key("x") or d.has_key("y")zx = "x" in d or "y" in dr:r;rrr�test_1dszTest_has_key.test_1cCsd}d}|�||�dS)Nzx = a.b.c.d.has_key("x") ** 3zx = ("x" in a.b.c.d) ** 3r:r;rrr�test_2iszTest_has_key.test_2cCsd}d}|�||�dS)Nz!x = a.b.has_key(1 + 2).__repr__()zx = (1 + 2 in a.b).__repr__()r:r;rrr�test_3nszTest_has_key.test_3cCsd}d}|�||�dS)Nz,x = a.b.has_key(1 + 2).__repr__() ** -3 ** 4z(x = (1 + 2 in a.b).__repr__() ** -3 ** 4r:r;rrr�test_4sszTest_has_key.test_4cCsd}d}|�||�dS)Nzx = a.has_key(f or g)zx = (f or g) in ar:r;rrr�test_5xszTest_has_key.test_5cCsd}d}|�||�dS)Nzx = a + b.has_key(c)zx = a + (c in b)r:r;rrr�test_6}szTest_has_key.test_6cCsd}d}|�||�dS)Nzx = a.has_key(lambda: 12)zx = (lambda: 12) in ar:r;rrr�test_7�szTest_has_key.test_7cCsd}d}|�||�dS)Nzx = a.has_key(a for a in b)zx = (a for a in b) in ar:r;rrr�test_8�szTest_has_key.test_8cCsd}d}|�||�dS)Nzif not a.has_key(b): passzif b not in a: passr:r;rrr�test_9�szTest_has_key.test_9cCsd}d}|�||�dS)Nz$if not a.has_key(b).__repr__(): passz if not (b in a).__repr__(): passr:r;rrr�test_10�szTest_has_key.test_10cCsd}d}|�||�dS)Nzif not a.has_key(b) ** 2: passzif not (b in a) ** 2: passr:r;rrr�test_11�szTest_has_key.test_11N)r6r*r7r	rBrCrDrErFrGrHrIrJrKrLrrrrrAasrAc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6S)7�
Test_applyZapplycCsd}d}|�||�dS)Nzx = apply(f, g + h)z
x = f(*g + h)r:r;rrrrB�szTest_apply.test_1cCsd}d}|�||�dS)Nzy = apply(f, g, h)zy = f(*g, **h)r:r;rrrrC�szTest_apply.test_2cCsd}d}|�||�dS)Nz z = apply(fs[0], g or h, h or g)zz = fs[0](*g or h, **h or g)r:r;rrrrD�szTest_apply.test_3cCsd}d}|�||�dS)Nzapply(f, (x, y) + t)zf(*(x, y) + t)r:r;rrrrE�szTest_apply.test_4cCsd}d}|�||�dS)Nzapply(f, args,)�f(*args)r:r;rrrrF�szTest_apply.test_5cCsd}d}|�||�dS)Nzapply(f, args, kwds,)�f(*args, **kwds)r:r;rrrrG�szTest_apply.test_6cCsd}d}|�||�dS)Nzx = apply(f+g, args)zx = (f+g)(*args)r:r;rrr�test_complex_1�szTest_apply.test_complex_1cCsd}d}|�||�dS)Nzx = apply(f*g, args)zx = (f*g)(*args)r:r;rrr�test_complex_2�szTest_apply.test_complex_2cCsd}d}|�||�dS)Nzx = apply(f**g, args)zx = (f**g)(*args)r:r;rrr�test_complex_3�szTest_apply.test_complex_3cCsd}d}|�||�dS)Nzx = apply(f.g, args)zx = f.g(*args)r:r;rrr�test_dotted_name�szTest_apply.test_dotted_namecCsd}d}|�||�dS)Nzx = apply(f[x], args)zx = f[x](*args)r:r;rrr�test_subscript�szTest_apply.test_subscriptcCsd}d}|�||�dS)Nzx = apply(f(), args)zx = f()(*args)r:r;rrr�	test_call�szTest_apply.test_callcCsd}d}|�||�dS)Nz"x = apply(a.b.c.d.e.f, args, kwds)zx = a.b.c.d.e.f(*args, **kwds)r:r;rrr�test_extreme�szTest_apply.test_extremecCsd}d}|�||�dS)Nz1apply(   # foo
          f, # bar
          args)rNr:r;rrr�test_weird_comments�szTest_apply.test_weird_commentscCsd}|�|�dS)Nzapply()r$�r�srrr�test_unchanged_1�szTest_apply.test_unchanged_1cCsd}|�|�dS)Nzapply(f)r$rXrrr�test_unchanged_2�szTest_apply.test_unchanged_2cCsd}|�|�dS)Nz	apply(f,)r$rXrrr�test_unchanged_3�szTest_apply.test_unchanged_3cCsd}|�|�dS)Nzapply(f, args, kwds, extras)r$rXrrr�test_unchanged_4�szTest_apply.test_unchanged_4cCsd}|�|�dS)Nzapply(f, *args, **kwds)r$rXrrr�test_unchanged_5�szTest_apply.test_unchanged_5cCsd}|�|�dS)Nzapply(f, *args)r$rXrrr�test_unchanged_6szTest_apply.test_unchanged_6cCsd}|�|�dS)Nzapply(f, **kwds)r$rXrrr�test_unchanged_6bszTest_apply.test_unchanged_6bcCsd}|�|�dS)Nz#apply(func=f, args=args, kwds=kwds)r$rXrrr�test_unchanged_7
szTest_apply.test_unchanged_7cCsd}|�|�dS)Nzapply(f, args=args, kwds=kwds)r$rXrrr�test_unchanged_8szTest_apply.test_unchanged_8cCsd}|�|�dS)Nzapply(f, args, kwds=kwds)r$rXrrr�test_unchanged_9szTest_apply.test_unchanged_9cCsd}d}|�||�dS)Nzapply(  f,  args,   kwds)rOr:�rr=r<rrr�test_space_1szTest_apply.test_space_1cCsd}d}|�||�dS)Nzapply(  f  ,args,kwds   )rOr:rdrrr�test_space_2szTest_apply.test_space_2N)r6r*r7r	rBrCrDrErFrGrPrQrRrSrTrUrVrWrZr[r\r]r^r_r`rarbrcrerfrrrrrM�s6	rMc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_reload�reloadcCsd}d}|�||�dS)Nz	reload(a)z$import importlib
importlib.reload(a)r:r;rrr�test#szTest_reload.testcCs,d}d}|�||�d}d}|�||�dS)Nzreload( a ) # commentz0import importlib
importlib.reload( a ) # commentzreload( a )  # commentz1import importlib
importlib.reload( a )  # commentr:r;rrr�test_comment(szTest_reload.test_commentcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzreload( 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 )r:r;rrr�
test_space2szTest_reload.test_spacecCs�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d	}|�|�dS)
Nzreload(a=1)zreload(f, g)z
reload(f, *h)zreload(f, *h, **i)zreload(f, **i)zreload(*h, **i)z
reload(*h)zreload(**i)zreload()r$rXrrr�test_unchanged?s$







zTest_reload.test_unchangedN)r6r*r7r	rirjrkrlrrrrrg s


rgc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_intern�interncCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzx =   intern(  a  )z"import sys
x =   sys.intern(  a  )z%y = intern("b" # test
              )z4import sys
y = sys.intern("b" # test
              )zz = intern(a+b+c.d,   )z&import sys
z = sys.intern(a+b+c.d,   )r:r;rrr�test_prefix_preservation^sz$Test_intern.test_prefix_preservationcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nz
x = intern(a)zimport sys
x = sys.intern(a)zz = 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", "")r:r;rrrrimszTest_intern.testcCsJd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzintern(a=1)zintern(f, g)z
intern(*h)zintern(**i)zintern()r$rXrrrrl|s



zTest_intern.test_unchangedN)r6r*r7r	rorirlrrrrrm[srmc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_reduce�reducecCsd}d}|�||�dS)Nzreduce(a, b, c)z,from functools import reduce
reduce(a, b, c)r:r;rrr�test_simple_call�szTest_reduce.test_simple_callcCsd}d}|�||�dS)Nzdef x(arg): reduce(sum, [])z8from functools import reduce
def x(arg): reduce(sum, [])r:r;rrr�
test_bug_7253�szTest_reduce.test_bug_7253cCsd}d}|�||�dS)Nzreduce(lambda x, y: x + y, seq)z<from functools import reduce
reduce(lambda x, y: x + y, seq)r:r;rrr�test_call_with_lambda�sz!Test_reduce.test_call_with_lambdacCsJd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nz	reduce(a)zreduce(a, b=42)zreduce(a, b, c, d)zreduce(**c)zreduce()r$rXrrrrl�s



zTest_reduce.test_unchangedN)r6r*r7r	rrrsrtrlrrrrrp�s
rpc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$S)%�
Test_print�printcCsd}d}|�||�dS)Nzprint 1,   1+1,   1+1+1zprint(1,   1+1,   1+1+1)r:r;rrrro�sz#Test_print.test_prefix_preservationcCs d}|�|�d}|�|�dS)N�print()�	print('')r$rXrrr�test_idempotency�s
zTest_print.test_idempotencycCs:tj|jj_d}|�|�d}|�|�d}|�|�dS)N�print(1, 1+1, 1+1+1)rwrx)rZ!python_grammar_no_print_statementrZdriverZgrammarr"rXrrr�"test_idempotency_print_as_function�s

z-Test_print.test_idempotency_print_as_functioncCsd}d}|�||�dS)Nzprint 1, 1+1, 1+1+1rzr:r;rrrrB�szTest_print.test_1cCsd}d}|�||�dS)Nz
print 1, 2zprint(1, 2)r:r;rrrrC�szTest_print.test_2cCsd}d}|�||�dS)Nrvrwr:r;rrrrD�szTest_print.test_3cCsd}d}|�||�dS)Nzprint whatever; printzprint(whatever); print()r:r;rrrrE�szTest_print.test_4cCsd}d}|�||�dS)Nzprint; print whatever;zprint(); print(whatever);r:r;rrrrF�szTest_print.test_5cCsd}d}|�||�dS)Nzprint (a, b, c)zprint((a, b, c))r:r;rrr�
test_tuple�szTest_print.test_tuplecCsd}d}|�||�dS)Nzprint 1, 2, 3,zprint(1, 2, 3, end=' ')r:r;rrr�test_trailing_comma_1�sz Test_print.test_trailing_comma_1cCsd}d}|�||�dS)Nzprint 1, 2,zprint(1, 2, end=' ')r:r;rrr�test_trailing_comma_2�sz Test_print.test_trailing_comma_2cCsd}d}|�||�dS)Nzprint 1,zprint(1, end=' ')r:r;rrr�test_trailing_comma_3�sz Test_print.test_trailing_comma_3cCsd}d}|�||�dS)Nzprint >>sys.stderr, 1, 2, 3zprint(1, 2, 3, file=sys.stderr)r:r;rrr�!test_vargs_without_trailing_comma�sz,Test_print.test_vargs_without_trailing_commacCsd}d}|�||�dS)Nzprint >>sys.stderr, 1, 2,z%print(1, 2, end=' ', file=sys.stderr)r:r;rrr�test_with_trailing_commasz#Test_print.test_with_trailing_commacCsd}d}|�||�dS)Nzprint >>sys.stderr, 1+1zprint(1+1, file=sys.stderr)r:r;rrr�test_no_trailing_commasz!Test_print.test_no_trailing_commacCsd}d}|�||�dS)Nzprint >>  sys.stderrzprint(file=sys.stderr)r:r;rrr�test_spaces_before_file
sz"Test_print.test_spaces_before_filecCs&d}|�|�d}d}|�||�dS)Nz<from __future__ import print_function
print('Hai!', end=' ')zprint 'Hello, world!'zprint('Hello, world!')�r"r)rrYr<r=rrr�test_with_future_print_functions

z*Test_print.test_with_future_print_functionN)r6r*r7r	roryr{rBrCrDrErFr|r}r~rr�r�r�r�r�rrrrru�s$ruc@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�	Test_exec�execcCsd}d}|�||�dS)Nz  exec code in ns1,   ns2z  exec(code, ns1,   ns2)r:r;rrrrosz"Test_exec.test_prefix_preservationcCsd}d}|�||�dS)Nz	exec code�
exec(code)r:r;rrrr>!szTest_exec.test_basiccCsd}d}|�||�dS)Nzexec code in ns�exec(code, ns)r:r;rrr�test_with_globals&szTest_exec.test_with_globalscCsd}d}|�||�dS)Nzexec code in ns1, ns2�exec(code, ns1, ns2)r:r;rrr�test_with_globals_locals+sz"Test_exec.test_with_globals_localscCsd}d}|�||�dS)Nzexec (a.b()) in nszexec((a.b()), ns)r:r;rrrrP0szTest_exec.test_complex_1cCsd}d}|�||�dS)Nzexec a.b() + c in nszexec(a.b() + c, ns)r:r;rrrrQ5szTest_exec.test_complex_2cCsd}|�|�dS)Nr�r$rXrrrrZ<szTest_exec.test_unchanged_1cCsd}|�|�dS)Nzexec (code)r$rXrrrr[@szTest_exec.test_unchanged_2cCsd}|�|�dS)Nr�r$rXrrrr\DszTest_exec.test_unchanged_3cCsd}|�|�dS)Nr�r$rXrrrr]HszTest_exec.test_unchanged_4N)r6r*r7r	ror>r�r�rPrQrZr[r\r]rrrrr�sr�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�	Test_repr�reprcCsd}d}|�||�dS)Nz
x =   `1 + 2`zx =   repr(1 + 2)r:r;rrrroOsz"Test_repr.test_prefix_preservationcCsd}d}|�||�dS)Nzx = `1 + 2`zx = repr(1 + 2)r:r;rrr�
test_simple_1TszTest_repr.test_simple_1cCsd}d}|�||�dS)Nzy = `x`zy = repr(x)r:r;rrr�
test_simple_2YszTest_repr.test_simple_2cCsd}d}|�||�dS)Nzz = `y`.__repr__()zz = repr(y).__repr__()r:r;rrr�test_complex^szTest_repr.test_complexcCsd}d}|�||�dS)Nz
x = `1, 2, 3`zx = repr((1, 2, 3))r:r;rrrr|cszTest_repr.test_tuplecCsd}d}|�||�dS)Nz
x = `1 + `2``zx = repr(1 + repr(2))r:r;rrr�test_nestedhszTest_repr.test_nestedcCsd}d}|�||�dS)Nzx = `1, 2 + `3, 4``zx = repr((1, 2 + repr((3, 4))))r:r;rrr�test_nested_tuplesmszTest_repr.test_nested_tuplesN)r6r*r7r	ror�r�r�r|r�r�rrrrr�Lsr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�Test_except�exceptcCsd}d}|�||�dS)Nzq
            try:
                pass
            except (RuntimeError, ImportError),    e:
                passzs
            try:
                pass
            except (RuntimeError, ImportError) as    e:
                passr:r;rrrrousz$Test_except.test_prefix_preservationcCsd}d}|�||�dS)NzV
            try:
                pass
            except Foo, e:
                pass�X
            try:
                pass
            except Foo as e:
                passr:r;rrr�test_simple�szTest_except.test_simplecCsd}d}|�||�dS)NzU
            try:
                pass
            except Foo,e:
                passr�r:r;rrr�"test_simple_no_space_before_target�sz.Test_except.test_simple_no_space_before_targetcCsd}d}|�||�dS)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:
                    passr:r;rrr�test_tuple_unpack�s		zTest_except.test_tuple_unpackcCsd}d}|�||�dS)Nzn
            try:
                pass
            except (RuntimeError, ImportError), e:
                passzp
            try:
                pass
            except (RuntimeError, ImportError) as e:
                passr:r;rrr�test_multi_class�szTest_except.test_multi_classcCsd}d}|�||�dS)Nza
            try:
                pass
            except Exception, [a, b]:
                passz�
            try:
                pass
            except Exception as xxx_todo_changeme:
                [a, b] = xxx_todo_changeme.args
                passr:r;rrr�test_list_unpack�szTest_except.test_list_unpackcCsd}d}|�||�dS)Nz_
            try:
                pass
            except Exception, d[5]:
                passz�
            try:
                pass
            except Exception as xxx_todo_changeme:
                d[5] = xxx_todo_changeme
                passr:r;rrr�test_weird_target_1�szTest_except.test_weird_target_1cCsd}d}|�||�dS)Nz`
            try:
                pass
            except Exception, a.foo:
                passz�
            try:
                pass
            except Exception as xxx_todo_changeme:
                a.foo = xxx_todo_changeme
                passr:r;rrr�test_weird_target_2�szTest_except.test_weird_target_2cCsd}d}|�||�dS)Nzb
            try:
                pass
            except Exception, a().foo:
                passz�
            try:
                pass
            except Exception as xxx_todo_changeme:
                a().foo = xxx_todo_changeme
                passr:r;rrr�test_weird_target_3�szTest_except.test_weird_target_3cCsd}d}|�||�dS)Nz�
            try:
                pass
            except Exception, a:
                pass
            except:
                passz�
            try:
                pass
            except Exception as a:
                pass
            except:
                passr:r;rrr�test_bare_except�szTest_except.test_bare_exceptcCsd}d}|�||�dS)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:
                passr:r;rrr�!test_bare_except_and_else_finally
sz-Test_except.test_bare_except_and_else_finallycCsd}d}|�||�dS)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:
                passr:r;rrr�+test_multi_fixed_excepts_before_bare_except's
	z7Test_except.test_multi_fixed_excepts_before_bare_exceptcCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	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()
            r:r;rrr�test_one_line_suites=sz Test_except.test_one_line_suitescCsd}|�|�dS)NzO
            try:
                pass
            except:
                passr$rXrrrrZmszTest_except.test_unchanged_1cCsd}|�|�dS)NzY
            try:
                pass
            except Exception:
                passr$rXrrrr[uszTest_except.test_unchanged_2cCsd}|�|�dS)Nzg
            try:
                pass
            except (Exception, SystemExit):
                passr$rXrrrr\}szTest_except.test_unchanged_3N)r6r*r7r	ror�r�r�r�r�r�r�r�r�r�r�r�rZr[r\rrrrr�rs"


0r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$S)%�
Test_raise�raisecCsd}d}|�||�dS)Nzraise Exception, 5�raise Exception(5)r:r;rrrr>�szTest_raise.test_basiccCs,d}d}|�||�d}d}|�||�dS)Nzraise Exception,5r�zraise   Exception,    5zraise   Exception(5)r:r;rrrro�sz#Test_raise.test_prefix_preservationcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzraise Exception, 5 # foozraise Exception(5) # foozraise E, (5, 6) % (a, b) # foozraise E((5, 6) % (a, b)) # fooz:def foo():
                    raise Exception, 5, 6 # foozIdef foo():
                    raise Exception(5).with_traceback(6) # foor:r;rrr�test_with_comments�szTest_raise.test_with_commentscCsd}d}|�||�dS)Nzraise Exception(5), None, tbz%raise Exception(5).with_traceback(tb)r:r;rrr�test_None_value�szTest_raise.test_None_valuecCsd}d}|�||�dS)Nzraise Exception, (5, 6, 7)zraise Exception(5, 6, 7)r:r;rrr�test_tuple_value�szTest_raise.test_tuple_valuecCsd}d}|�||�dS)Nzraise E, (5, 6) % (a, b)zraise E((5, 6) % (a, b))r:r;rrr�test_tuple_detection�szTest_raise.test_tuple_detectioncCsd}d}|�||�dS)Nzraise (((E1, E2), E3), E4), V�raise E1(V)r:r;rrr�test_tuple_exc_1�szTest_raise.test_tuple_exc_1cCsd}d}|�||�dS)Nzraise (E1, (E2, E3), E4), Vr�r:r;rrr�test_tuple_exc_2�szTest_raise.test_tuple_exc_2cCsd}|�|d�dS)Nzraise 'foo'�+Python 3 does not support string exceptions�r&rXrrr�test_string_exc�szTest_raise.test_string_exccCsd}|�|d�dS)Nzraise "foo", 5r�r�rXrrr�test_string_exc_val�szTest_raise.test_string_exc_valcCsd}|�|d�dS)Nzraise "foo", 5, 6r�r�rXrrr�test_string_exc_val_tb�sz!Test_raise.test_string_exc_val_tbcCsd}d}|�||�dS)Nz4def foo():
                    raise Exception, 5, 6�Cdef foo():
                    raise Exception(5).with_traceback(6)r:r;rrr�	test_tb_1�szTest_raise.test_tb_1cCsd}d}|�||�dS)Nzhdef foo():
                    a = 5
                    raise Exception, 5, 6
                    b = 6�wdef foo():
                    a = 5
                    raise Exception(5).with_traceback(6)
                    b = 6r:r;rrr�	test_tb_2�szTest_raise.test_tb_2cCsd}d}|�||�dS)Nz2def foo():
                    raise Exception,5,6r�r:r;rrr�	test_tb_3�szTest_raise.test_tb_3cCsd}d}|�||�dS)Nzfdef foo():
                    a = 5
                    raise Exception,5,6
                    b = 6r�r:r;rrr�	test_tb_4�szTest_raise.test_tb_4cCsd}d}|�||�dS)Nz<def foo():
                    raise Exception, (5, 6, 7), 6zIdef foo():
                    raise Exception(5, 6, 7).with_traceback(6)r:r;rrr�	test_tb_5�szTest_raise.test_tb_5cCsd}d}|�||�dS)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 = 6r:r;rrr�	test_tb_6�szTest_raise.test_tb_6N)r6r*r7r	r>ror�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s$	r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�
Test_throw�throwcCsd}d}|�||�dS)Nzg.throw(Exception, 5)�g.throw(Exception(5))r:r;rrrrBszTest_throw.test_1cCsd}d}|�||�dS)Nzg.throw(Exception,5)r�r:r;rrrrCszTest_throw.test_2cCsd}d}|�||�dS)Nzg.throw(Exception, (5, 6, 7))zg.throw(Exception(5, 6, 7))r:r;rrrrDszTest_throw.test_3cCsd}d}|�||�dS)Nz5 + g.throw(Exception, 5)z5 + g.throw(Exception(5))r:r;rrrrEszTest_throw.test_4cCsd}|�|d�dS)Nzg.throw("foo")r�r�rXrrr�test_warn_1szTest_throw.test_warn_1cCsd}|�|d�dS)Nzg.throw("foo", 5)r�r�rXrrr�test_warn_2!szTest_throw.test_warn_2cCsd}|�|d�dS)Nzg.throw("foo", 5, 6)r�r�rXrrr�test_warn_3%szTest_throw.test_warn_3cCsd}|�|�dS)Nzg.throw(Exception)r$rXrrr�test_untouched_1+szTest_throw.test_untouched_1cCsd}|�|�dS)Nzg.throw(Exception(5, 6))r$rXrrr�test_untouched_2/szTest_throw.test_untouched_2cCsd}|�|�dS)Nz5 + g.throw(Exception(5, 6))r$rXrrr�test_untouched_33szTest_throw.test_untouched_3cCsd}d}|�||�dS)Nz7def foo():
                    g.throw(Exception, 5, 6)�Fdef foo():
                    g.throw(Exception(5).with_traceback(6))r:r;rrrr�9szTest_throw.test_tb_1cCsd}d}|�||�dS)Nzkdef foo():
                    a = 5
                    g.throw(Exception, 5, 6)
                    b = 6�zdef foo():
                    a = 5
                    g.throw(Exception(5).with_traceback(6))
                    b = 6r:r;rrrr�@szTest_throw.test_tb_2cCsd}d}|�||�dS)Nz5def foo():
                    g.throw(Exception,5,6)r�r:r;rrrr�KszTest_throw.test_tb_3cCsd}d}|�||�dS)Nzidef foo():
                    a = 5
                    g.throw(Exception,5,6)
                    b = 6r�r:r;rrrr�RszTest_throw.test_tb_4cCsd}d}|�||�dS)Nz?def foo():
                    g.throw(Exception, (5, 6, 7), 6)zLdef foo():
                    g.throw(Exception(5, 6, 7).with_traceback(6))r:r;rrrr�]szTest_throw.test_tb_5cCsd}d}|�||�dS)Nzsdef foo():
                    a = 5
                    g.throw(Exception, (5, 6, 7), 6)
                    b = 6z�def foo():
                    a = 5
                    g.throw(Exception(5, 6, 7).with_traceback(6))
                    b = 6r:r;rrrr�dszTest_throw.test_tb_6cCsd}d}|�||�dS)Nz;def foo():
                    a + g.throw(Exception, 5, 6)zJdef foo():
                    a + g.throw(Exception(5).with_traceback(6))r:r;rrr�	test_tb_7oszTest_throw.test_tb_7cCsd}d}|�||�dS)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 = 6r:r;rrr�	test_tb_8vszTest_throw.test_tb_8N)r6r*r7r	rBrCrDrEr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s&r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�	Test_long�longcCsd}d}|�||�dS)Nzx = long(x)z
x = int(x)r:r;rrrrB�szTest_long.test_1cCsd}d}|�||�dS)Nzy = isinstance(x, long)zy = isinstance(x, int)r:r;rrrrC�szTest_long.test_2cCsd}d}|�||�dS)Nzz = type(x) in (int, long)zz = type(x) in (int, int)r:r;rrrrD�szTest_long.test_3cCsfd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzlong = Truez
s.long = Truezdef long(): passzclass long(): passzdef f(long): passzdef f(g, long): passzdef f(x, long=True): passr$rXrrrrl�s





zTest_long.test_unchangedcCsd}d}|�||�dS)Nzx =   long(  x  )zx =   int(  x  )r:r;rrrro�sz"Test_long.test_prefix_preservationN)	r6r*r7r	rBrCrDrlrorrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�
Test_execfileZexecfilecCs|d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�dS)
Nzexecfile("fn")z4exec(compile(open("fn", "rb").read(), "fn", 'exec'))zexecfile("fn", glob)z:exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob)zexecfile("fn", glob, loc)z?exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob, loc)zexecfile("fn", globals=glob)zBexec(compile(open("fn", "rb").read(), "fn", 'exec'), globals=glob)zexecfile("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)r:r;rrr�test_conversion�s$zTest_execfile.test_conversioncCs,d}d}|�||�d}d}|�||�dS)Nzexecfile( "fn" )z6exec(compile(open( "fn", "rb" ).read(), "fn", 'exec'))zexecfile("fn",  globals = glob)zEexec(compile(open("fn", "rb").read(), "fn", 'exec'),  globals = glob)r:r;rrr�test_spacing�szTest_execfile.test_spacingN)r6r*r7r	r�r�rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_isinstance�
isinstancecCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	Nzisinstance(x, (int, int, int))zisinstance(x, int)z,isinstance(x, (int, float, int, int, float))zisinstance(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))r:r;rrr�test_remove_multiple_items�sz*Test_isinstance.test_remove_multiple_itemscCsd}d}|�||�dS)Nz4if    isinstance(  foo(), (  bar, bar, baz )) : passz/if    isinstance(  foo(), (  bar, baz )) : passr:r;rrrro�sz(Test_isinstance.test_prefix_preservationcCs|�d�dS)Nzisinstance(x, (str, int))r$�rrrrrl�szTest_isinstance.test_unchangedN)r6r*r7r	r�rorlrrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHS)I�	Test_dict�dictcCs|d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�dS)Nzif   d. keys  (  )  : passz if   list(d. keys  (  ))  : passzif   d. items  (  )  : passz!if   list(d. items  (  ))  : passzif   d. iterkeys  ( )  : passzif   iter(d. keys  ( ))  : passz"[i for i in    d.  iterkeys(  )  ]z[i for i in    d.  keys(  )  ]zif   d. viewkeys  ( )  : passzif   d. keys  ( )  : passz"[i for i in    d.  viewkeys(  )  ]r:r;rrrro�s$z"Test_dict.test_prefix_preservationcCs|d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d}|�||�dS)
Nzd.keys() # foozlist(d.keys()) # foozd.items()  # foozlist(d.items())  # foozd.iterkeys()  # fooziter(d.keys())  # fooz/[i for i in d.iterkeys() # foo
               ]z+[i for i in d.keys() # foo
               ]zd.viewitems()  # foor:r;rrr�test_trailing_comment
s$zTest_dict.test_trailing_commentcCsFtjD]:}d|}|�|�d|}|�|�d|}|�|�qdS)Nzs = %s(d.keys())zs = %s(d.values())zs = %s(d.items())�rZconsuming_callsr")r�wrapperrYrrrrl*s


zTest_dict.test_unchangedcCs,d}d}|�||�d}d}|�||�dS)N�d.keys()�list(d.keys())za[0].foo().keys()zlist(a[0].foo().keys())r:r;rrr�test_015szTest_dict.test_01cCsd}d}|�||�dS)N�	d.items()zlist(d.items())r:r;rrr�test_02>szTest_dict.test_02cCsd}d}|�||�dS)N�
d.values()zlist(d.values())r:r;rrr�test_03CszTest_dict.test_03cCsd}d}|�||�dS)Nzd.iterkeys()�iter(d.keys())r:r;rrr�test_04HszTest_dict.test_04cCsd}d}|�||�dS)Nz
d.iteritems()ziter(d.items())r:r;rrr�test_05MszTest_dict.test_05cCsd}d}|�||�dS)Nzd.itervalues()ziter(d.values())r:r;rrr�test_06RszTest_dict.test_06cCsd}|�|�dS)Nr�r$rXrrr�test_07WszTest_dict.test_07cCsd}|�|�dS)N�sorted(d.keys())r$rXrrr�test_08[szTest_dict.test_08cCsd}d}|�||�dS)Nr�ziter(list(d.keys()))r:r;rrr�test_09_szTest_dict.test_09cCsd}d}|�||�dS)Nz
foo(d.keys())zfoo(list(d.keys()))r:r;rrrrKdszTest_dict.test_10cCsd}d}|�||�dS)N�for i in d.keys(): print iz for i in list(d.keys()): print ir:r;rrrrLiszTest_dict.test_11cCsd}d}|�||�dS)Nzfor i in d.iterkeys(): print ir�r:r;rrr�test_12nszTest_dict.test_12cCsd}d}|�||�dS)N�[i for i in d.keys()]z for i in list(d.keys())]r:r;rrr�test_13sszTest_dict.test_13cCsd}d}|�||�dS)Nz[i for i in d.iterkeys()]r�r:r;rrr�test_14xszTest_dict.test_14cCsd}d}|�||�dS)N�(i for i in d.keys())z(i for i in list(d.keys()))r:r;rrr�test_15}szTest_dict.test_15cCsd}d}|�||�dS)Nz(i for i in d.iterkeys())r�r:r;rrr�test_16�szTest_dict.test_16cCsd}d}|�||�dS)Nziter(d.iterkeys())r�r:r;rrr�test_17�szTest_dict.test_17cCsd}d}|�||�dS)Nzlist(d.iterkeys())r�r:r;rrr�test_18�szTest_dict.test_18cCsd}d}|�||�dS)Nzsorted(d.iterkeys())r�r:r;rrr�test_19�szTest_dict.test_19cCsd}d}|�||�dS)Nzfoo(d.iterkeys())zfoo(iter(d.keys()))r:r;rrr�test_20�szTest_dict.test_20cCsd}d}|�||�dS)Nzprint h.iterkeys().next()zprint iter(h.keys()).next()r:r;rrr�test_21�szTest_dict.test_21cCsd}d}|�||�dS)Nzprint h.keys()[0]zprint list(h.keys())[0]r:r;rrr�test_22�szTest_dict.test_22cCsd}d}|�||�dS)Nzprint list(h.iterkeys().next())z!print list(iter(h.keys()).next())r:r;rrr�test_23�szTest_dict.test_23cCsd}d}|�||�dS)Nzfor x in h.keys()[0]: print xz#for x in list(h.keys())[0]: print xr:r;rrr�test_24�szTest_dict.test_24cCsd}d}|�||�dS)Nzd.viewkeys()r�r:r;rrr�test_25�szTest_dict.test_25cCsd}d}|�||�dS)Nz
d.viewitems()r�r:r;rrr�test_26�szTest_dict.test_26cCsd}d}|�||�dS)Nzd.viewvalues()r�r:r;rrr�test_27�szTest_dict.test_27cCsd}d}|�||�dS)Nz[i for i in d.viewkeys()]r�r:r;rrr�test_28�szTest_dict.test_28cCsd}d}|�||�dS)Nz(i for i in d.viewkeys())r�r:r;rrr�test_29�szTest_dict.test_29cCsd}d}|�||�dS)Nziter(d.viewkeys())r�r:r;rrr�test_30�szTest_dict.test_30cCsd}d}|�||�dS)Nzlist(d.viewkeys())r�r:r;rrr�test_31�szTest_dict.test_31cCsd}d}|�||�dS)Nzsorted(d.viewkeys())r�r:r;rrr�test_32�szTest_dict.test_32N)'r6r*r7r	ror�rlr�r�r�r�r�r�r�r�r�rKrLr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��sH	r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�Test_xrange�xrangecCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzx =    xrange(  10  )zx =    range(  10  )zx = xrange(  1  ,  10   )zx = range(  1  ,  10   )zx = xrange(  0  ,  10 ,  2 )zx = range(  0  ,  10 ,  2 )r:r;rrrro�sz$Test_xrange.test_prefix_preservationcCsd}d}|�||�dS)Nzx = xrange(10)z
x = range(10)r:r;rrr�test_single_arg�szTest_xrange.test_single_argcCsd}d}|�||�dS)Nzx = xrange(1, 10)zx = range(1, 10)r:r;rrr�
test_two_args�szTest_xrange.test_two_argscCsd}d}|�||�dS)Nzx = xrange(0, 10, 2)zx = range(0, 10, 2)r:r;rrr�test_three_args�szTest_xrange.test_three_argscCshd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�dS)Nzx = range(10, 3, 9)zx = list(range(10, 3, 9))zx = foo(range(10, 3, 9))zx = foo(list(range(10, 3, 9)))zx = range(10, 3, 9) + [4]zx = list(range(10, 3, 9)) + [4]zx = range(10)[::-1]zx = list(range(10))[::-1]zx = range(10)  [3]zx = list(range(10))  [3]r:r;rrr�test_wrap_in_list�szTest_xrange.test_wrap_in_listcCs,d}d}|�||�d}d}|�||�dS)Nzfor i in xrange(10):
    j=izfor i in range(10):
    j=iz[i for i in xrange(10)]�[i for i in range(10)]r:r;rrr�test_xrange_in_forszTest_xrange.test_xrange_in_forcCs|�d�|�d�dS)Nzfor i in range(10): passrr$r�rrr�test_range_in_fors
zTest_xrange.test_range_in_forcCs|�d�dS)Nzx in range(10, 3, 9)r$r�rrr�test_in_contains_testsz!Test_xrange.test_in_contains_testcCstjD]}|�d|�qdS)Nza = %s(range(10))r�)r�callrrr�test_in_consuming_contexts
z%Test_xrange.test_in_consuming_contextN)
r6r*r7r	ror�r�rrrrrrrrrrr��s
	r�cs$eZdZ�fdd�Zdd�Z�ZS)�Test_xrange_with_reducecstt|��ddg�dS)Nr�rq)�superrrr��r)rrr!szTest_xrange_with_reduce.setUpcCsd}d}|�||�dS)Nzreduce(x, xrange(5))z0from functools import reduce
reduce(x, range(5))r:r;rrr�test_double_transform$sz-Test_xrange_with_reduce.test_double_transform)r6r*r7rr�
__classcell__rrr
rrsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�Test_raw_inputZ	raw_inputcCs,d}d}|�||�d}d}|�||�dS)Nzx =    raw_input(   )zx =    input(   )zx = raw_input(   ''   )�x = input(   ''   )r:r;rrrro-sz'Test_raw_input.test_prefix_preservationcCsd}d}|�||�dS)Nzx = raw_input()�x = input()r:r;rrrrB6szTest_raw_input.test_1cCsd}d}|�||�dS)Nzx = raw_input('')�
x = input('')r:r;rrrrC;szTest_raw_input.test_2cCsd}d}|�||�dS)Nzx = raw_input('prompt')�x = input('prompt')r:r;rrrrD@szTest_raw_input.test_3cCsd}d}|�||�dS)Nzx = raw_input(foo(a) + 6)zx = input(foo(a) + 6)r:r;rrrrEEszTest_raw_input.test_4cCsd}d}|�||�dS)Nzx = raw_input(invite).split()zx = input(invite).split()r:r;rrrrFJszTest_raw_input.test_5cCsd}d}|�||�dS)Nz x = raw_input(invite) . split ()zx = input(invite) . split ()r:r;rrrrGOszTest_raw_input.test_6cCsd}d}|�||�dS)Nzx = int(raw_input())zx = int(input())r:r;rrrrITszTest_raw_input.test_8N)r6r*r7r	rorBrCrDrErFrGrIrrrrr
*s	r
c@s2eZdZdZdddddddgZd	d
�Zdd�Zd
S)�Test_funcattrsZ	funcattrsZclosure�doc�name�defaults�code�globalsr�cCsH|jD]<}d|}d|}|�||�d|}d|}|�||�qdS)Nz	a.func_%s�a.__%s__zself.foo.func_%s.foo_bar�self.foo.__%s__.foo_bar��attrsr�r�attrr<r=rrrri^s
zTest_funcattrs.testcCsF|jD]:}d|}|�|�d|}|�|�d|}|�|�qdS)Nzfoo(func_%s + 5)�
f(foo.__%s__)�f(foo.__%s__.foo)�rr"�rrrYrrrrlhs


zTest_funcattrs.test_unchangedN�r6r*r7r	rrirlrrrrrYs
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_xreadlinesZ
xreadlinescCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzfor x in f.xreadlines(): passzfor x in f: passz!for x in foo().xreadlines(): passzfor x in foo(): passz'for x in (5 + foo()).xreadlines(): passzfor x in (5 + foo()): passr:r;rrrrUvszTest_xreadlines.test_callcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzfoo(f.xreadlines + 5)zfoo(f.__iter__ + 5)zfoo(f().xreadlines + 5)zfoo(f().__iter__ + 5)zfoo((5 + f()).xreadlines + 5)zfoo((5 + f()).__iter__ + 5)r:r;rrr�
test_attr_ref�szTest_xreadlines.test_attr_refcCs<d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzfor x in f.xreadlines(5): passz for x in f.xreadlines(k=5): passz$for x in f.xreadlines(*k, **v): passzfoo(xreadlines)r$rXrrrrl�s


zTest_xreadlines.test_unchangedN)r6r*r7r	rUr$rlrrrrr#ss

r#c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ImportsFixerTestscCsP|j��D]@\}}d|}d|}|�||�d|}d|}|�||�q
dS)N�	import %szimport foo, %s, bar��modules�itemsr�r�old�newr<r=rrr�test_import_module�sz$ImportsFixerTests.test_import_modulecCsl|j��D]\\}}d|}d|}|�||�d|}d|}|�||�d|}d|}|�||�q
dS)Nzfrom %s import foozfrom %s import foo, barzfrom %s import (yes, no)r'r*rrr�test_import_from�sz"ImportsFixerTests.test_import_fromcCsP|j��D]@\}}d|}d|}|�||�d|}d|}|�||�q
dS)Nzimport %s as foo_barr'r*rrr�test_import_module_as�sz'ImportsFixerTests.test_import_module_ascCs4|j��D]$\}}d|}d|}|�||�q
dS)Nzfrom %s import foo as barr'r*rrr�test_import_from_as�sz%ImportsFixerTests.test_import_from_ascCs4|j��D]$\}}d|}d|}|�||�q
dS)N�from %s import *r'r*rrr�	test_star�szImportsFixerTests.test_starcCs�|j��D]�\}}d||f}d||f}|�||�d||f}d||f}|�||�d|f}|�|�d|||f}d|||f}|�||�d||f}d||f}|�||�q
dS)NzG
                import %s
                foo(%s.bar)
                zJ
                from %s import x
                %s = 23
                zJ
                def f():
                    %s.method()
                zJ
                import %s
                %s.bar(%s.foo)
                z@
                import %s
                x.%s
                )r(r)rr")rr+r,r<r=rYrrr�test_import_module_usage�sB�����
����z*ImportsFixerTests.test_import_module_usageN)	r6r*r7r-r.r/r0r2r3rrrrr%�s

r%c@s,eZdZdZddlmZdd�Zdd�ZdS)	�Test_imports�imports���MAPPINGcCsd}d}|�||�dS)Nzimport urlparse, cStringIOzimport urllib.parse, ior:r;rrr�test_multiple_importssz"Test_imports.test_multiple_importscCsd}d}|�||�dS)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())
            r:r;rrr�test_multiple_imports_as	sz%Test_imports.test_multiple_imports_asN)	r6r*r7r	�fixes.fix_importsr8r(r9r:rrrrr4sr4c@seZdZdZddlmZdS)�
Test_imports2�imports2r6r7N)r6r*r7r	�fixes.fix_imports2r8r(rrrrr<sr<cs$eZdZ�fdd�Zdd�Z�ZS)�Test_imports_fixer_ordercsRtt|��ddg�ddlm}|��|_ddlm}dD]}|||j|<q:dS)Nr5r=r6r7)�dbhash�dumbdbm�dbm�gdbm)r	r?rr>r8�copyr(r;)rZmapping2Zmapping1�keyr
rrrs
zTest_imports_fixer_order.setUpcCsdD]}||_|�d�qdS)N)r5r=�import)r	r5)rZfixrrr�$test_after_local_imports_refactoring$sz=Test_imports_fixer_order.test_after_local_imports_refactoring)r6r*r7rrGrrrr
rr?sr?c@sTeZdZdZddlmZdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dS)�Test_urllib�urllibr6r7cCsD|j��D]4\}}d|}dd�ttd�|��}|�||�q
dS)Nr&r(r)r(r)r �maprr)rr+�changesr<r=rrrr-.szTest_urllib.test_import_modulec
Cs�|j��D]�\}}g}|D]�\}}|D]D}|�|�d||f}d||f}|�||�d|}	|�|	�q&d|d�|�f}d|d�|�f}|�||�dd�|�}	|�|	�qd|d�|�f}d�dd�|D��}|�||�q
dS)N�from %s import %s�from foo import %sr(�
cSs"g|]\}}d|d�|�f�qS)rLr()r )r+r,�membersrrrr-Js�z0Test_urllib.test_import_from.<locals>.<listcomp>)r(r)�appendrr"r )
rr+rKZall_membersr,rO�memberr<r=rYrrrr.4s(

�zTest_urllib.test_import_fromcCs$|jD]}d|}|�|d�qdS)Nzimport %s as fooz#This module is now multiple modules�r(r&�rr+rYrrrr/Ns
z!Test_urllib.test_import_module_ascCs||j��D]l\}}|D]^\}}|D]P}d||f}d||f}|�||�d|||f}d|||f}|�||�q"qq
dS)N�from %s import %s as foo_barzfrom %s import %s as blah, %sr')rr+rKr,rOrQr<r=rrrr0SszTest_urllib.test_import_from_ascCs$|jD]}d|}|�|d�qdS)Nr1zCannot handle star importsrRrSrrrr2^s
zTest_urllib.test_starcCs,d}d}|�||�d}d}|�||�dS)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
r:r;rrr�
test_indentedcszTest_urllib.test_indentedc		Cs�|j��D]�\}}|D]�\}}|D]v}d�dd�|j|D��}d|||f}d|||f}|�||�d|||||f}d|||||f}|�||�q"qq
dS)Nr(cSsg|]\}}|�qSrr)r+r4Zmemsrrrr-�sz8Test_urllib.test_import_module_usage.<locals>.<listcomp>z^
                        import %s
                        foo(%s.%s)
                        z`
                        import %s
                        %s.%s(%s.%s)
                        )r(r)r r)	rr+rKr,rOrQZ
new_importr<r=rrrr3~s(
�����z$Test_urllib.test_import_module_usageN)r6r*r7r	Zfixes.fix_urllibr8r(r-r.r/r0r2rUr3rrrrrH*srHc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
Test_input�inputcCs,d}d}|�||�d}d}|�||�dS)Nzx =   input(   )zx =   eval(input(   ))rzx = eval(input(   ''   ))r:r;rrrro�sz#Test_input.test_prefix_preservationcCsd}d}|�||�dS)Nzx = input()  #  foozx = eval(input())  #  foor:r;rrrr��sz Test_input.test_trailing_commentcCs.d}|�|�d}|�|�d}|�|�dS)N�x = eval(input())�x = eval(input(''))�x = eval(input(foo(5) + 9))r$rXrrrry�s

zTest_input.test_idempotencycCsd}d}|�||�dS)NrrXr:r;rrrrB�szTest_input.test_1cCsd}d}|�||�dS)NrrYr:r;rrrrC�szTest_input.test_2cCsd}d}|�||�dS)Nrzx = eval(input('prompt'))r:r;rrrrD�szTest_input.test_3cCsd}d}|�||�dS)Nzx = input(foo(5) + 9)rZr:r;rrrrE�szTest_input.test_4N)r6r*r7r	ror�ryrBrCrDrErrrrrV�s	
rVc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*S)+�Test_tuple_paramsZtuple_paramscCsd}|�|�dS)Nzdef foo(): passr$rXrrrrZ�sz"Test_tuple_params.test_unchanged_1cCsd}|�|�dS)Nzdef foo(a, b, c): passr$rXrrrr[�sz"Test_tuple_params.test_unchanged_2cCsd}|�|�dS)Nzdef foo(a=3, b=4, c=5): passr$rXrrrr\�sz"Test_tuple_params.test_unchanged_3cCsd}d}|�||�dS)Nz8
            def foo(((a, b), c)):
                x = 5zn
            def foo(xxx_todo_changeme):
                ((a, b), c) = xxx_todo_changeme
                x = 5r:r;rrrrB�szTest_tuple_params.test_1cCsd}d}|�||�dS)Nz;
            def foo(((a, b), c), d):
                x = 5zq
            def foo(xxx_todo_changeme, d):
                ((a, b), c) = xxx_todo_changeme
                x = 5r:r;rrrrC�szTest_tuple_params.test_2cCsd}d}|�||�dS)Nz@
            def foo(((a, b), c), d) -> e:
                x = 5zv
            def foo(xxx_todo_changeme, d) -> e:
                ((a, b), c) = xxx_todo_changeme
                x = 5r:r;rrrrD�szTest_tuple_params.test_3cCsd}d}|�||�dS)Nz/
            def foo(((a, b), c)): x = 5; y = 7zV
            def foo(xxx_todo_changeme): ((a, b), c) = xxx_todo_changeme; x = 5; y = 7r:r;rrr�test_semicolon�sz Test_tuple_params.test_semicoloncCsd}d}|�||�dS)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 = 5r:r;rrr�
test_keywords�szTest_tuple_params.test_keywordscCsd}d}|�||�dS)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 = 5r:r;rrr�test_varargs
szTest_tuple_params.test_varargscCsd}d}|�||�dS)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 = 5r:r;rrr�test_multi_1szTest_tuple_params.test_multi_1cCsd}d}|�||�dS)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 = 5r:r;rrr�test_multi_2!szTest_tuple_params.test_multi_2cCsd}d}|�||�dS)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 = 5r:r;rrr�test_docstring-sz Test_tuple_params.test_docstringcCsd}|�|�dS)N�lambda x: x + 5r$rXrrr�test_lambda_no_change;sz'Test_tuple_params.test_lambda_no_changecCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzlambda (x): x + 5rbzlambda(x): x + 5zlambda ((((x)))): x + 5zlambda((((x)))): x + 5r:r;rrr�test_lambda_parens_single_arg?sz/Test_tuple_params.test_lambda_parens_single_argcCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzlambda (x, y): x + f(y)zlambda x_y: x_y[0] + f(x_y[1])zlambda(x, y): x + f(y)zlambda (((x, y))): x + f(y)zlambda(((x, y))): x + f(y)r:r;rrr�test_lambda_simplePsz$Test_tuple_params.test_lambda_simplecCs,d}d}|�||�d}d}|�||�dS)Nzlambda (x,): x + f(x)zlambda x1: x1[0] + f(x1[0])zlambda (((x,))): x + f(x)r:r;rrr�test_lambda_one_tupleasz'Test_tuple_params.test_lambda_one_tuplecCsd}d}|�||�dS)Nzlambda (x, y): x + x + f(x) + xz0lambda x_y: x_y[0] + x_y[0] + f(x_y[0]) + x_y[0]r:r;rrr�test_lambda_simple_multi_usejsz.Test_tuple_params.test_lambda_simple_multi_usecCsd}d}|�||�dS)Nzlambda (x, y): y + xzlambda x_y: x_y[1] + x_y[0]r:r;rrr�test_lambda_simple_reverseosz,Test_tuple_params.test_lambda_simple_reversecCs,d}d}|�||�d}d}|�||�dS)Nzlambda (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 + zr:r;rrr�test_lambda_nestedtsz$Test_tuple_params.test_lambda_nestedcCsd}d}|�||�dS)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])r:r;rrr�test_lambda_nested_multi_use}sz.Test_tuple_params.test_lambda_nested_multi_useN)r6r*r7r	rZr[r\rBrCrDr\r]r^r_r`rarcrdrerfrgrhrirjrrrrr[�s*		r[c@s*eZdZdZdddgZdd�Zdd�Zd	S)
�Test_methodattrsZmethodattrs�funcr�classcCsd|jD]X}d|}|dkr d}nd|}|�||�d|}|dkrJd}nd|}|�||�qdS)Nza.im_%srmza.__self__.__class__rzself.foo.im_%s.foo_barz#self.foo.__self__.__class__.foo_barrrrrrrri�s
zTest_methodattrs.testcCsF|jD]:}d|}|�|�d|}|�|�d|}|�|�qdS)Nzfoo(im_%s + 5)rrr r!rrrrl�s


zTest_methodattrs.test_unchangedNr"rrrrrk�s
rkc@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\S)]�	Test_next�nextcCsd}d}|�||�dS)Nz	it.next()znext(it)r:r;rrrrB�szTest_next.test_1cCsd}d}|�||�dS)Nza.b.c.d.next()z
next(a.b.c.d)r:r;rrrrC�szTest_next.test_2cCsd}d}|�||�dS)Nz(a + b).next()z
next((a + b))r:r;rrrrD�szTest_next.test_3cCsd}d}|�||�dS)Nz
a().next()z	next(a())r:r;rrrrE�szTest_next.test_4cCsd}d}|�||�dS)Nza().next() + bz
next(a()) + br:r;rrrrF�szTest_next.test_5cCsd}d}|�||�dS)Nzc(      a().next() + b)zc(      next(a()) + b)r:r;rrrrG�szTest_next.test_6cCsd}d}|�||�dS)NzU
            for a in b:
                foo(a)
                a.next()
            zT
            for a in b:
                foo(a)
                next(a)
            r:r;rrr�test_prefix_preservation_1�sz$Test_next.test_prefix_preservation_1cCsd}d}|�||�dS)Nzq
            for a in b:
                foo(a) # abc
                # def
                a.next()
            zp
            for a in b:
                foo(a) # abc
                # def
                next(a)
            r:r;rrr�test_prefix_preservation_2�sz$Test_next.test_prefix_preservation_2cCsd}d}|j||dd�dS)Nzj
            next = 5
            for a in b:
                foo(a)
                a.next()
            zn
            next = 5
            for a in b:
                foo(a)
                a.__next__()
            T�rr:r;rrr�test_prefix_preservation_3�sz$Test_next.test_prefix_preservation_3cCsd}d}|j||dd�dS)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__()
            Trrr:r;rrr�test_prefix_preservation_4�sz$Test_next.test_prefix_preservation_4cCsd}d}|j||dd�dS)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__())
            Trrr:r;rrr�test_prefix_preservation_5�sz$Test_next.test_prefix_preservation_5cCsd}d}|�||�dS)Nze
            for a in b:
                foo(foo(a), # abc
                    a.next())
            zd
            for a in b:
                foo(foo(a), # abc
                    next(a))
            r:r;rrr�test_prefix_preservation_6	sz$Test_next.test_prefix_preservation_6cCsd}d}|�||�dS)Nz[
            class A:
                def next(self):
                    pass
            z_
            class A:
                def __next__(self):
                    pass
            r:r;rrr�
test_method_1	szTest_next.test_method_1cCsd}d}|�||�dS)Nzc
            class A(object):
                def next(self):
                    pass
            zg
            class A(object):
                def __next__(self):
                    pass
            r:r;rrr�
test_method_2(	szTest_next.test_method_2cCsd}d}|�||�dS)NzX
            class A:
                def next(x):
                    pass
            z\
            class A:
                def __next__(x):
                    pass
            r:r;rrr�
test_method_35	szTest_next.test_method_3cCsd}d}|�||�dS)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
            r:r;rrr�
test_method_4B	szTest_next.test_method_4cCsd}|�|�dS)Nza
            class A:
                def next(self, a, b):
                    pass
            r$rXrrr�test_method_unchanged[	szTest_next.test_method_unchangedcCsd}|�|d�dS)Nzy
            next = foo

            class A:
                def next(self, a, b):
                    pass
            �)Calls to builtin next() possibly shadowedr�rXrrr�test_shadowing_assign_simplec	sz&Test_next.test_shadowing_assign_simplecCsd}|�|d�dS)Nz~
            (next, a) = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_assign_tuple_1m	sz'Test_next.test_shadowing_assign_tuple_1cCsd}|�|d�dS)Nz�
            (a, (b, (next, c)), a) = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_assign_tuple_2w	sz'Test_next.test_shadowing_assign_tuple_2cCsd}|�|d�dS)Nz~
            [next, a] = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_assign_list_1�	sz&Test_next.test_shadowing_assign_list_1cCsd}|�|d�dS)Nz�
            [a, [b, [next, c]], a] = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_assign_list_2�	sz&Test_next.test_shadowing_assign_list_2cCsd}|�|d�dS)Nz�
            def foo():
                __builtin__.next = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_builtin_assign�	szTest_next.test_builtin_assigncCsd}|�|d�dS)Nz�
            def foo():
                (a, __builtin__.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_builtin_assign_in_tuple�	sz&Test_next.test_builtin_assign_in_tuplecCsd}|�|d�dS)Nz�
            def foo():
                [a, __builtin__.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_builtin_assign_in_list�	sz%Test_next.test_builtin_assign_in_listcCsd}|�|�dS)Nz�
            def foo():
                A.next = foo

            class A:
                def next(self, a, b):
                    pass
            r$rXrrr�test_assign_to_next�	szTest_next.test_assign_to_nextcCsd}|�|�dS)Nz�
            def foo():
                (a, A.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r$rXrrr�test_assign_to_next_in_tuple�	sz&Test_next.test_assign_to_next_in_tuplecCsd}|�|�dS)Nz�
            def foo():
                [a, A.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r$rXrrr�test_assign_to_next_in_list�	sz%Test_next.test_assign_to_next_in_listcCsd}|�|d�dS)Nz�
            import foo.bar as next

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_1�	sz!Test_next.test_shadowing_import_1cCsd}|�|d�dS)Nz�
            import bar, bar.foo as next

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_2�	sz!Test_next.test_shadowing_import_2cCsd}|�|d�dS)Nz�
            import bar, bar.foo as next, baz

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_3�	sz!Test_next.test_shadowing_import_3cCsd}|�|d�dS)Nz�
            from x import next

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_from_1�	sz&Test_next.test_shadowing_import_from_1cCsd}|�|d�dS)Nz�
            from x.a import next

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_from_2�	sz&Test_next.test_shadowing_import_from_2cCsd}|�|d�dS)Nz�
            from x import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_from_3	
sz&Test_next.test_shadowing_import_from_3cCsd}|�|d�dS)Nz�
            from x.a import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_import_from_4
sz&Test_next.test_shadowing_import_from_4cCsd}|�|d�dS)Nz�
            def next(a):
                pass

            class A:
                def next(self, a, b):
                    pass
            r|r�rXrrr�test_shadowing_funcdef_1
sz"Test_next.test_shadowing_funcdef_1cCsd}d}|�||d�dS)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|r%r;rrr�test_shadowing_funcdef_2(
s

z"Test_next.test_shadowing_funcdef_2cCsd}|�|d�dS)NzW
            def f():
                global next
                next = 5
            r|r�rXrrr�test_shadowing_global_1?
sz!Test_next.test_shadowing_global_1cCsd}|�|d�dS)Nz]
            def f():
                global a, next, b
                next = 5
            r|r�rXrrr�test_shadowing_global_2G
sz!Test_next.test_shadowing_global_2cCsd}|�|d�dS)Nze
            for next in it():
                pass

            b = 5
            c = 6
            r|r�rXrrr�test_shadowing_for_simpleO
sz#Test_next.test_shadowing_for_simplecCsd}|�|d�dS)Nzh
            for next, b in it():
                pass

            b = 5
            c = 6
            r|r�rXrrr�test_shadowing_for_tuple_1Y
sz$Test_next.test_shadowing_for_tuple_1cCsd}|�|d�dS)Nzp
            for a, (next, c), b in it():
                pass

            b = 5
            c = 6
            r|r�rXrrr�test_shadowing_for_tuple_2c
sz$Test_next.test_shadowing_for_tuple_2cCsd}d}|�||�dS)Nzgnext = g.nextzgnext = g.__next__r:r;rrr�test_noncall_access_1m
szTest_next.test_noncall_access_1cCsd}d}|�||�dS)Nz
f(g.next + 5)zf(g.__next__ + 5)r:r;rrr�test_noncall_access_2r
szTest_next.test_noncall_access_2cCsd}d}|�||�dS)Nzf(g().next + 5)zf(g().__next__ + 5)r:r;rrr�test_noncall_access_3w
szTest_next.test_noncall_access_3N)1r6r*r7r	rBrCrDrErFrGrprqrsrtrurvrwrxryrzr{r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrn�s\



















rnc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Test_nonzero�nonzerocCsd}d}|�||�dS)Nzb
            class A:
                def __nonzero__(self):
                    pass
            z_
            class A:
                def __bool__(self):
                    pass
            r:r;rrrrB
szTest_nonzero.test_1cCsd}d}|�||�dS)Nzj
            class A(object):
                def __nonzero__(self):
                    pass
            �g
            class A(object):
                def __bool__(self):
                    pass
            r:r;rrrrC�
szTest_nonzero.test_2cCsd}|�|�dS)Nr�r$rXrrrrZ�
szTest_nonzero.test_unchanged_1cCsd}|�|�dS)Nzm
            class A(object):
                def __nonzero__(self, a):
                    pass
            r$rXrrrr[�
szTest_nonzero.test_unchanged_2cCsd}|�|�dS)NzE
            def __nonzero__(self):
                pass
            r$rXrrr�test_unchanged_func�
sz Test_nonzero.test_unchanged_funcN)	r6r*r7r	rBrCrZr[r�rrrrr�|
s

r�c@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�Test_numliteralsZnumliteralscCsd}d}|�||�dS)NZ0755�0o755r:r;rrr�test_octal_1�
szTest_numliterals.test_octal_1cCsd}d}|�||�dS)Nza = 12L�a = 12r:r;rrr�test_long_int_1�
sz Test_numliterals.test_long_int_1cCsd}d}|�||�dS)Nza = 12lr�r:r;rrr�test_long_int_2�
sz Test_numliterals.test_long_int_2cCsd}d}|�||�dS)Nz	b = 0x12lzb = 0x12r:r;rrr�
test_long_hex�
szTest_numliterals.test_long_hexcCs,d}d}|�||�d}d}|�||�dS)Nzb =   0x12Lz
b =   0x12zb = 0755 # spamzb = 0o755 # spamr:r;rrr�test_comments_and_spacing�
sz*Test_numliterals.test_comments_and_spacingcCsd}|�|�dS)N�5r$rXrrr�test_unchanged_int�
sz#Test_numliterals.test_unchanged_intcCsd}|�|�dS)Nz5.0r$rXrrr�test_unchanged_float�
sz%Test_numliterals.test_unchanged_floatcCsd}|�|�dS)Nr�r$rXrrr�test_unchanged_octal�
sz%Test_numliterals.test_unchanged_octalcCsd}|�|�dS)NZ0xABCr$rXrrr�test_unchanged_hex�
sz#Test_numliterals.test_unchanged_hexcCsd}|�|�dS)Nz5.0e10r$rXrrr�test_unchanged_exp�
sz#Test_numliterals.test_unchanged_expcCsd}|�|�dS)Nz5 + 4jr$rXrrr�test_unchanged_complex_int�
sz+Test_numliterals.test_unchanged_complex_intcCsd}|�|�dS)Nz
5.4 + 4.9jr$rXrrr�test_unchanged_complex_float�
sz-Test_numliterals.test_unchanged_complex_floatcCs d}|�|�d}|�|�dS)NZ4jz4.4jr$rXrrr�test_unchanged_complex_bare�
s
z,Test_numliterals.test_unchanged_complex_bareN)r6r*r7r	r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��
s	r�c@s8eZdZdZddiZdd�Zdd�Zdd	�Zd
d�ZdS)
�Test_renames�renames�sys)Zmaxint�maxsizecCsVt|j���D]B\}\}}d||f}d||f}|�||�d|}|�|�qdS)NrLrM)�listr(r)rr")r�modr+r,r<r=rYrrrr.�
szTest_renames.test_import_fromcCsDt|j���D]0\}\}}d||f}d||f}|�||�qdS)NrT�r�r(r)r�rr�r+r,r<r=rrrr0sz Test_renames.test_import_from_ascCsLt|j���D]8\}\}}d||||f}d||||f}|�||�qdS)NzJ
                import %s
                foo(%s, %s.%s)
                r�r�rrrr3s
�
�z%Test_renames.test_import_module_usagecCsLt|j���D]8\}\}}d||||f}d||||f}|�||�qdS)NzO
                from %s import %s
                foo(%s, %s)
                r�r�rrr�XXX_test_from_import_usages
�
�z'Test_renames.XXX_test_from_import_usageN)	r6r*r7r	r(r.r0r3r�rrrrr��
s	r�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�Test_unicode�unicodecCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzunicode( x)zstr( x)z unicode(x )z str(x )z u'h'z 'h'r:r;rrr�test_whitespace#szTest_unicode.test_whitespacecCsd}d}|�||�dS)Nzunicode(x, y, z)zstr(x, y, z)r:r;rrr�test_unicode_call0szTest_unicode.test_unicode_callcCsd}d}|�||�dS)Nzunichr(u'h')zchr('h')r:r;rrr�test_unichr5szTest_unicode.test_unichrcCsd}d}|�||�dS)Nzu"x"z"x"r:r;rrr�test_unicode_literal_1:sz#Test_unicode.test_unicode_literal_1cCsd}d}|�||�dS)Nzur'x'zr'x'r:r;rrr�test_unicode_literal_2?sz#Test_unicode.test_unicode_literal_2cCsd}d}|�||�dS)Nz
UR'''x''' z	R'''x''' r:r;rrr�test_unicode_literal_3Dsz#Test_unicode.test_unicode_literal_3cCs,d}d}|�||�d}d}|�||�dS)N�'\\\u20ac\U0001d121\\u20ac'z'\\\\u20ac\\U0001d121\\u20ac'�r'\\\u20ac\U0001d121\\u20ac'r:r;rrr�test_native_literal_escape_uIsz)Test_unicode.test_native_literal_escape_ucCs,d}d}|�||�d}d}|�||�dS)Nzb'\\\u20ac\U0001d121\\u20ac'zbr'\\\u20ac\U0001d121\\u20ac'r:r;rrr�test_bytes_literal_escape_uRsz(Test_unicode.test_bytes_literal_escape_ucCs,d}d}|�||�d}d}|�||�dS)Nzu'\\\u20ac\U0001d121\\u20ac'r�zur'\\\u20ac\U0001d121\\u20ac'r�r:r;rrr�test_unicode_literal_escape_u[sz*Test_unicode.test_unicode_literal_escape_ucCs@d}|d}|d}|�||�|d}|d}|�||�dS)Nz(from __future__ import unicode_literals
r�r�r:)r�fr<r=rrr�$test_native_unicode_literal_escape_udsz1Test_unicode.test_native_unicode_literal_escape_uN)r6r*r7r	r�r�r�r�r�r�r�r�r�r�rrrrr� s
			r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Test_filter�filtercCs,d}d}|�||�d}d}|�||�dS)Nz#x =   filter(    foo,     'abc'   )z)x =   list(filter(    foo,     'abc'   ))zx =   filter(  None , 'abc'  )z x =   [_f for _f in 'abc' if _f]r:r;rrrrorsz$Test_filter.test_prefix_preservationcCshd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d}d	}|�||�dS)
Nzx = filter(None, 'abc')zx = [_f for _f in 'abc' if _f]zx = len(filter(f, 'abc'))zx = 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)]r:r;rrr�test_filter_basic{szTest_filter.test_filter_basiccCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzx = filter(None, 'abc')[0]z!x = [_f for _f in 'abc' if _f][0]zx = 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]r:r;rrr�test_filter_trailers�sz Test_filter.test_filter_trailerscCsd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d	}|�|�d
}|�|�d}|�|�d}|�|�d
}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzb.join(filter(f, 'abc'))z#(a + foo(5)).join(filter(f, 'abc'))ziter(filter(f, 'abc'))zlist(filter(f, 'abc'))zlist(filter(f, 'abc'))[0]zset(filter(f, 'abc'))zset(filter(f, 'abc')).pop()ztuple(filter(f, 'abc'))zany(filter(f, 'abc'))zall(filter(f, 'abc'))zsum(filter(f, 'abc'))zsorted(filter(f, 'abc'))z"sorted(filter(f, 'abc'), key=blah)z%sorted(filter(f, 'abc'), key=blah)[0]zenumerate(filter(f, 'abc'))z$enumerate(filter(f, 'abc'), start=1)zfor i in filter(f, 'abc'): passz[x for x in filter(f, 'abc')]z(x for x in filter(f, 'abc'))r$�rr=rrr�test_filter_nochange�sL

















z Test_filter.test_filter_nochangecCs4d}|�|�d}d}|�||�d}|�|�dS)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�rdrrr�test_future_builtins�s
z Test_filter.test_future_builtinsN)	r6r*r7r	ror�r�r�r�rrrrr�os	(r�csXeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�ZS)�Test_maprJcs&|�d||�tt|��||�dS)Nz!from future_builtins import map; )r"r	r�rr;r
rrr�szTest_map.checkcCsd}d}|�||�dS)Nzx =    map(   f,    'abc'   )z#x =    list(map(   f,    'abc'   ))r:r;rrrro�sz!Test_map.test_prefix_preservationcCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	Nzx = map(f, 'abc')[0]zx = list(map(f, 'abc'))[0]zx = map(None, l)[0]zx = list(l)[0]zx = map(lambda x:x, l)[0]zx = [x for x in l][0]zx = map(f, 'abc')[0][1]zx = list(map(f, 'abc'))[0][1]r:r;rrr�test_map_trailers�szTest_map.test_map_trailerscCsd}d}|�||�dS)Nzx = map(f, 'abc')   #   fooz!x = list(map(f, 'abc'))   #   foor:r;rrrr��szTest_map.test_trailing_commentcCsd}|�|d�dS)Nzx = map(None, a, b, c)z5cannot convert map(None, ...) with multiple argumentsr�rXrrr�!test_None_with_multiple_arguments�sz*Test_map.test_None_with_multiple_argumentscCs~d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d}|�||�d
}d}|�||d�dS)
Nzx = map(f, 'abc')zx = list(map(f, 'abc'))zx = len(map(f, 'abc', 'def'))z#x = len(list(map(f, 'abc', 'def')))zx = map(None, 'abc')zx = list('abc')z x = map(lambda x: x+1, range(4))zx = [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))
            zYou should use a for loop here)rr#r;rrr�test_map_basic�s$zTest_map.test_map_basiccCsd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d	}|�|�d
}|�|�d}|�|�d}|�|�d
}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzb.join(map(f, 'abc'))z (a + foo(5)).join(map(f, 'abc'))ziter(map(f, 'abc'))zlist(map(f, 'abc'))zlist(map(f, 'abc'))[0]zset(map(f, 'abc'))zset(map(f, 'abc')).pop()ztuple(map(f, 'abc'))zany(map(f, 'abc'))zall(map(f, 'abc'))zsum(map(f, 'abc'))zsorted(map(f, 'abc'))zsorted(map(f, 'abc'), key=blah)z"sorted(map(f, 'abc'), key=blah)[0]zenumerate(map(f, 'abc'))z!enumerate(map(f, 'abc'), start=1)zfor i in map(f, 'abc'): passz[x for x in map(f, 'abc')]z(x for x in map(f, 'abc'))r$r�rrr�test_map_nochange sL

















zTest_map.test_map_nochangecCs4d}|�|�d}d}|�||�d}|�|�dS)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�rdrrrr�Hs
zTest_map.test_future_builtins)
r6r*r7r	rror�r�r�r�r�r�rrrr
rr��s"(r�cs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�Test_zip�zipcs&|�d||�tt|��||�dS)Nz!from future_builtins import zip; )r"r	r�rr;r
rrrVszTest_zip.checkcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nz	x = zip()zx = list(zip())zx = zip(a, b, c)zx = list(zip(a, b, c))zx = len(zip(a, b))zx = len(list(zip(a, b)))r:r;rrr�test_zip_basicZszTest_zip.test_zip_basiccCs,d}d}|�||�d}d}|�||�dS)Nzx = zip(a, b, c)[0]zx = list(zip(a, b, c))[0]zx = zip(a, b, c)[0][1]zx = list(zip(a, b, c))[0][1]r:r;rrr�test_zip_trailersgszTest_zip.test_zip_trailerscCsd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d	}|�|�d
}|�|�d}|�|�d}|�|�d
}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzb.join(zip(a, b))z(a + foo(5)).join(zip(a, b))ziter(zip(a, b))zlist(zip(a, b))zlist(zip(a, b))[0]zset(zip(a, b))zset(zip(a, b)).pop()ztuple(zip(a, b))zany(zip(a, b))zall(zip(a, b))zsum(zip(a, b))zsorted(zip(a, b))zsorted(zip(a, b), key=blah)zsorted(zip(a, b), key=blah)[0]zenumerate(zip(a, b))zenumerate(zip(a, b), start=1)zfor i in zip(a, b): passz[x for x in zip(a, b)]z(x for x in zip(a, b))r$r�rrr�test_zip_nochangepsL

















zTest_zip.test_zip_nochangecCs4d}|�|�d}d}|�||�d}|�|�dS)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�rdrrrr��s
zTest_zip.test_future_builtins)
r6r*r7r	rr�r�r�r�rrrr
rr�Ss
	(r�c@seZdZdZdd�ZdS)�Test_standarderrorZ
standarderrorcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzx =    StandardError()zx =    Exception()zx = StandardError(a, b, c)zx = Exception(a, b, c)zf(2 + StandardError(a, b, c))zf(2 + Exception(a, b, c))r:r;rrrri�szTest_standarderror.testN)r6r*r7r	rirrrrr��sr�c@seZdZdZdd�ZdS)�
Test_types�typescCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d}|�||�d
}d}|�||�d}d
}|�||�dS)Nztypes.StringType�bytesztypes.DictTyper�ztypes . IntType�intztypes.ListTyper�ztypes.LongTypeztypes.NoneTypez
type(None)ztypes.StringTypesz(str,)r:r;rrr�test_basic_types_convert�s*z#Test_types.test_basic_types_convertN)r6r*r7r	r�rrrrr��sr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�Test_idiomsZidiomscCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzwhile 1: foo()zwhile True: foo()zwhile   1: foo()zwhile   True: foo()z8
            while 1:
                foo()
            z;
            while True:
                foo()
            r:r;rrr�
test_while�szTest_idioms.test_whilecCs<d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzwhile 11: foo()zwhile 0: foo()zwhile foo(): foo()zwhile []: foo()r$rXrrr�test_while_unchanged�s


z Test_idioms.test_while_unchangedcCs,d}d}|�||�d}d}|�||�dS)Nztype(x) == T�isinstance(x, T)zif   type(x) == T: pass�if   isinstance(x, T): passr:r;rrr�test_eq_simple�szTest_idioms.test_eq_simplecCs,d}d}|�||�d}d}|�||�dS)NzT == type(x)r�zif   T == type(x): passr�r:r;rrr�test_eq_reverse�szTest_idioms.test_eq_reversecCs,d}d}|�||�d}d}|�||�dS)Nztype(x+y) == d.get('T')�isinstance(x+y, d.get('T'))ztype(   x  +  y) == d.get('T')�isinstance(x  +  y, d.get('T'))r:r;rrr�test_eq_expression
szTest_idioms.test_eq_expressioncCs,d}d}|�||�d}d}|�||�dS)Nztype(x) is Tr�zif   type(x) is T: passr�r:r;rrr�test_is_simple
szTest_idioms.test_is_simplecCs,d}d}|�||�d}d}|�||�dS)NzT is type(x)r�zif   T is type(x): passr�r:r;rrr�test_is_reverse
szTest_idioms.test_is_reversecCs,d}d}|�||�d}d}|�||�dS)Nztype(x+y) is d.get('T')r�ztype(   x  +  y) is d.get('T')r�r:r;rrr�test_is_expression#
szTest_idioms.test_is_expressioncCs,d}d}|�||�d}d}|�||�dS)Nztype(x) is not T�not isinstance(x, T)zif   type(x) is not T: pass�if   not isinstance(x, T): passr:r;rrr�test_is_not_simple,
szTest_idioms.test_is_not_simplecCs,d}d}|�||�d}d}|�||�dS)NzT is not type(x)r�zif   T is not type(x): passr�r:r;rrr�test_is_not_reverse5
szTest_idioms.test_is_not_reversecCs,d}d}|�||�d}d}|�||�dS)Nztype(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'))r:r;rrr�test_is_not_expression>
sz"Test_idioms.test_is_not_expressioncCs,d}d}|�||�d}d}|�||�dS)Nztype(x) != Tr�zif   type(x) != T: passr�r:r;rrr�test_ne_simpleG
szTest_idioms.test_ne_simplecCs,d}d}|�||�d}d}|�||�dS)NzT != type(x)r�zif   T != type(x): passr�r:r;rrr�test_ne_reverseP
szTest_idioms.test_ne_reversecCs,d}d}|�||�d}d}|�||�dS)Nztype(x+y) != d.get('T')r�ztype(   x  +  y) != d.get('T')r�r:r;rrr�test_ne_expressionY
szTest_idioms.test_ne_expressioncCsd}|�|�dS)Nztype(x).__name__r$r�rrr�test_type_unchangedb
szTest_idioms.test_type_unchangedcCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�d
}d}|�||�d}d}|�||�dS)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 commentsr:r;rrr�test_sort_list_callf
s0zTest_idioms.test_sort_list_callcCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�d
}d}|�||�dS)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)
            r:r;rrr�test_sort_simple_expr�
s*z!Test_idioms.test_sort_simple_exprcCs d}|�|�d}|�|�dS)NzM
            v = list(t)
            w.sort()
            foo(w)
            zN
            v = list(t)
            v.sort(u)
            foo(v)
            r$rXrrr�test_sort_unchangeds
zTest_idioms.test_sort_unchangedN)r6r*r7r	r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s&
												dRr�c@seZdZdZdd�ZdS)�Test_basestring�
basestringcCsd}d}|�||�dS)Nzisinstance(x, basestring)zisinstance(x, str)r:r;rrr�test_basestring.szTest_basestring.test_basestringN)r6r*r7r	r�rrrrr�+sr�c@s eZdZdZdd�Zdd�ZdS)�Test_buffer�buffercCsd}d}|�||�dS)Nz
x = buffer(y)zx = memoryview(y)r:r;rrr�test_buffer6szTest_buffer.test_buffercCsd}d}|�||�dS)Nzbuffer(y)[4:5]zmemoryview(y)[4:5]r:r;rrr�test_slicing;szTest_buffer.test_slicingN)r6r*r7r	rrrrrrr�3sr�c@s eZdZdZdd�Zdd�ZdS)�Test_future�futurecCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzfrom __future__ import bracesrz'# comment
from __future__ import bracesz
# comment
z'from __future__ import braces
# commentz

# commentr:r;rrr�test_futureCszTest_future.test_futurecCs|�d�dS)Nrv�r5r�rrr�test_run_orderPszTest_future.test_run_orderN)r6r*r7r	rrrrrrr@s
rc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�Test_itertools�	itertoolscCs<dD]2}dD](}||d|}||}|�||�qqdS)N)z
itertools.r)rJr�r��ir:)rrrr
r�r<r=rrr�checkallVs
zTest_itertools.checkallcCsd}d}|�||�dS)Nzitertools.izip(a, b)z	zip(a, b)r:r;rrr�test_0`szTest_itertools.test_0cCsd}d}|�||�dS)Nz%s(f, a)�rr;rrrrBgszTest_itertools.test_1cCs,d}d}|�||�d}d}|�||�dS)Nzitertools.ifilterfalse(a, b)zitertools.filterfalse(a, b)zitertools.izip_longest(a, b)zitertools.zip_longest(a, b)r:r;rrr�test_qualifiedlszTest_itertools.test_qualifiedcCs,d}d}|�||�d}d}|�||�dS)Nzifilterfalse(a, b)zfilterfalse(a, b)zizip_longest(a, b)zzip_longest(a, b)r:r;rrrrCuszTest_itertools.test_2cCsd}d}|�||�dS)Nz    %s(f, a)r
r;rrrre~szTest_itertools.test_space_1cCs,d}d}|�||�d}d}|�||�dS)Nz     itertools.ifilterfalse(a, b)z    itertools.filterfalse(a, b)z     itertools.izip_longest(a, b)z    itertools.zip_longest(a, b)r:r;rrrrf�szTest_itertools.test_space_2cCs|�ddd�dS)NrJr�r�rr�rrrr�szTest_itertools.test_run_orderN)r6r*r7r	rrrBrrCrerfrrrrrrSs
			rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�Test_itertools_importsZitertools_importscCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nz%from itertools import imap, izip, foo�from itertools import fooz*from itertools import bar, imap, izip, foozfrom itertools import bar, fooz'from itertools import chain, imap, izipzfrom itertools import chainr:r;rrr�test_reduced�sz#Test_itertools_imports.test_reducedcCsd}d}|�||�dS)Nz%#foo
from itertools import imap, izipz#foo
r:r;rrr�
test_comments�sz$Test_itertools_imports.test_commentscCs,d}d}|�||�d}d}|�||�dS)Nz from itertools import imap, iziprzfrom itertools import izipr:r;rrr�	test_none�sz Test_itertools_imports.test_nonecCsbd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d}|�|�dS)Nz-from itertools import izip, bar as bang, imapz!from itertools import bar as bangz-from itertools import izip as _zip, imap, barzfrom itertools import barz"from itertools import imap as _maprz0from itertools import imap as _map, izip as _zip)rr")rr<r=rYrrr�test_import_as�sz%Test_itertools_imports.test_import_ascCsndD]d}d|f}d|f}|�||�d|f}d|f}|�||�d|f}d|f}|�||�qdS)N)�filterfalse�zip_longestzfrom itertools import i%szfrom itertools import %sz$from itertools import imap, i%s, foozfrom itertools import %s, fooz#from itertools import bar, i%s, fooz"from itertools import bar, %s, foor:)rrr<r=rrr�test_ifilter_and_zip_longest�s





z3Test_itertools_imports.test_ifilter_and_zip_longestcCsd}|�|�dS)Nzfrom itertools import *r$rXrrr�test_import_star�sz'Test_itertools_imports.test_import_starcCsd}|�|�dS)Nrr$rXrrrrl�sz%Test_itertools_imports.test_unchangedN)r6r*r7r	rrrrrrrlrrrrr�s
	rcs�eZdZdZ�fdd�Zdd�Z�fdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z�ZS)(�Test_importrFcsDtt����g�_t��_d�_�fdd�}ddlm}||_	dS)NTcs�j�|��jp|�jkSr)�
files_checkedrP�
always_exists�
present_files�rr�rr�fake_exists�sz&Test_import.setUp.<locals>.fake_existsr��
fix_import)
r	rrr�setrr�
lib2to3.fixesr �exists)rrr r
r�rr�szTest_import.setUpcCsddlm}tjj|_dS)Nrr)r"r �os�pathr#)rr rrr�tearDown�szTest_import.tearDowncs2d|_tt|��||�d|_tt|��|�dS)NTF)rr	rrr"r;r
rr�
check_both�szTest_import.check_bothcs�dd�}d|_tdg�|_dtjjdddd	f}|d
�d|d�f}|D]n�g|_�|_|�d
�tj�	��r|tj�	��d�nd�t�fdd�|D��}|�
d�|�t|j�|�qDdS)NcSstjj�|�d��S)N�/)r$r%�pathsepr �split)r%rrr�p�sz)Test_import.test_files_checked.<locals>.pF�__init__.pyz.pyz.pycz.soz.slz.pydz
/spam/eggs.pyzni.pyz../../shrubbery.pyz
import jamz/jamZjamc3s|]}�|VqdSrr)r+�extrrr�	<genexpr>sz1Test_import.test_files_checked.<locals>.<genexpr>)rr!rr$r%�seprr
r"�dirname�addr)rr+Zexpected_extensionsZ
names_to_testZexpected_checksrrr�test_files_checked�s

zTest_import.test_files_checkedcCs$d}d|_tdg�|_|�|�dS)N�
import barF�bar.py�rr!rr"rXrrr�test_not_in_package
szTest_import.test_not_in_packagecCs&d}d|_tddg�|_|�|�dS)Nz1from __future__ import absolute_import
import barFr,r4r5rXrrr�!test_with_absolute_import_enabledsz-Test_import.test_with_absolute_import_enabledcCs,d}d}d|_tddg�|_|�||�dS)Nr3�from . import barFr,r4)rr!rrr;rrr�test_in_packages
zTest_import.test_in_packagecCs4d}d}d|_tddtjjg�|_|�||�dS)Nr3r8Fr,Zbar)rr!r$r%r/rrr;rrr�test_import_from_package s
z$Test_import.test_import_from_packagecCsd}|�|�dS)Nr8r$rXrrr�test_already_relative_import'sz(Test_import.test_already_relative_importcCsd}d}|�||�dS)Nzimport bar # Foozfrom . import bar # Foor:r;rrr�test_comments_and_indent+sz$Test_import.test_comments_and_indentcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzfrom foo import bar, bazzfrom .foo import bar, bazzfrom foo import barzfrom .foo import barzfrom foo import (bar, baz)zfrom .foo import (bar, baz)�r'r;rrr�	test_from0szTest_import.test_fromcCsd}d}|�||�dS)Nzfrom green.eggs import hamzfrom .green.eggs import hamr=r;rrr�test_dotted_from=szTest_import.test_dotted_fromcCsd}d}|�||�dS)Nz"from green.eggs import ham as spamz#from .green.eggs import ham as spamr=r;rrr�test_from_asBszTest_import.test_from_ascCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	Nz
import foozfrom . import foo�import foo, barzfrom . import foo, barzimport foo, bar, xzfrom . import foo, bar, xzimport x, y, zzfrom . import x, y, zr=r;rrr�test_importGszTest_import.test_importcCs,d}d}|�||�d}d}|�||�dS)Nzimport foo as xzfrom . import foo as xzimport a as b, b as c, c as dz$from . import a as b, b as c, c as dr=r;rrrrXszTest_import.test_import_ascCs(d|_tddg�|_d}|�|d�dS)NFzfoo.pyr,rAz#absolute and local imports together)rr!rr&rXrrr�test_local_and_absoluteasz#Test_import.test_local_and_absolutecCsd}d}|�||�dS)Nzimport foo.barzfrom . import foo.barr=r;rrr�test_dotted_importhszTest_import.test_dotted_importcCsd}d}|�||�dS)Nzimport foo.bar as bangzfrom . import foo.bar as bangr=r;rrr�test_dotted_import_asmsz!Test_import.test_dotted_import_ascCsd}d}|�||�dS)Nz1
        # prefix
        import foo.bar
        z8
        # prefix
        from . import foo.bar
        r=r;rrr�test_prefixrszTest_import.test_prefix)r6r*r7r	rr&r'r2r6r7r9r:r;r<r>r?r@rBrrCrDrErFrrrr
rr�s(
	rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Test_set_literalZset_literalcCs�d}d}|�||�d}d}|�||�d}d}|�||�d}|�||�d}d}|�||�d	}|�||�d
}d}|�||�d}d
}|�||�d}d}|�||�dS)Nzset([1, 2, 3])z	{1, 2, 3}zset((1, 2, 3))z	set((1,))�{1}zset([1])zset((a, b))z{a, b}zset([a, b])zset((a*234, f(args=23)))z{a*234, f(args=23)}zset([a*23, f(23)])z
{a*23, f(23)}zset([a-234**23])z{a-234**23}r:r;rrrr>�s2zTest_set_literal.test_basiccCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	Nzset([x for x in y])z{x for x in y}zset([x for x in y if x == m])z{x for x in y if x == m}zset([x for x in y for a in b])z{x for x in y for a in b}zset([f(x) - 23 for x in y])z{f(x) - 23 for x in y}r:r;rrr�test_listcomps�szTest_set_literal.test_listcompscCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�d
}d}|�||�dS)Nzset( [1, 2])z{1, 2}z
set([1 ,  2])z{1 ,  2}z
set([ 1 ])z{ 1 }z
set( [1] )rHzset([  1,  2  ])z{  1,  2  }zset([x  for x in y ])z{x  for x in y }z<set(
                   [1, 2]
               )
            z{1, 2}
r:r;rrrr��s*z Test_set_literal.test_whitespacecCs,d}d}|�||�d}d}|�||�dS)Nzset((1, 2)) # Hiz{1, 2} # HizZ
            # Foo
            set( # Bar
               (1, 2)
            )
            z2
            # Foo
            {1, 2}
            r:r;rrrr�szTest_set_literal.test_commentscCsXd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzset()zset(a)zset(a, b, c)zset(x for x in y)zset(x for x in y if z)zset(a*823-23**2 + f(23))r$rXrrrrl�s




zTest_set_literal.test_unchangedN)	r6r*r7r	r>rIr�rrlrrrrrG~s# rGc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�Test_sys_excZsys_exccCsd}d}|�||�dS)Nzsys.exc_typezsys.exc_info()[0]r:r;rrrrszTest_sys_exc.test_0cCsd}d}|�||�dS)Nz
sys.exc_valuezsys.exc_info()[1]r:r;rrrrBszTest_sys_exc.test_1cCsd}d}|�||�dS)Nzsys.exc_tracebackzsys.exc_info()[2]r:r;rrrrC
szTest_sys_exc.test_2cCsd}d}|�||�dS)Nzsys.exc_type # Foozsys.exc_info()[0] # Foor:r;rrrrDszTest_sys_exc.test_3cCsd}d}|�||�dS)Nzsys.  exc_typezsys.  exc_info()[0]r:r;rrrrEszTest_sys_exc.test_4cCsd}d}|�||�dS)Nzsys  .exc_typezsys  .exc_info()[0]r:r;rrrrFszTest_sys_exc.test_5N)
r6r*r7r	rrBrCrDrErFrrrrrJ�srJc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
Test_parenZparencCsd}d}|�||�dS)Nz[i for i in 1, 2 ]z[i for i in (1, 2) ]r:r;rrrr"szTest_paren.test_0cCsd}d}|�||�dS)Nz[i for i in 1, 2, ]z[i for i in (1, 2,) ]r:r;rrrrB'szTest_paren.test_1cCsd}d}|�||�dS)Nz[i for i  in     1, 2 ]z[i for i  in     (1, 2) ]r:r;rrrrC,szTest_paren.test_2cCsd}d}|�||�dS)Nz[i for i in 1, 2 if i]z[i for i in (1, 2) if i]r:r;rrrrD1szTest_paren.test_3cCsd}d}|�||�dS)Nz[i for i in 1,    2    ]z[i for i in (1,    2)    ]r:r;rrrrE6szTest_paren.test_4cCsd}d}|�||�dS)Nz(i for i in 1, 2)�(i for i in (1, 2))r:r;rrrrF;szTest_paren.test_5cCsd}d}|�||�dS)Nz(i for i in 1   ,2   if i)z(i for i in (1   ,2)   if i)r:r;rrrrG@szTest_paren.test_6cCsd}|�|�dS)Nz[i for i in (1, 2)]r$rXrrr�test_unchanged_0EszTest_paren.test_unchanged_0cCsd}|�|�dS)Nz[i for i in foo()]r$rXrrrrZIszTest_paren.test_unchanged_1cCsd}|�|�dS)Nz[i for i in (1, 2) if nothing]r$rXrrrr[MszTest_paren.test_unchanged_2cCsd}|�|�dS)NrLr$rXrrrr\QszTest_paren.test_unchanged_3cCsd}|�|�dS)Nz[i for i in m]r$rXrrrr]UszTest_paren.test_unchanged_4N)r6r*r7r	rrBrCrDrErFrGrMrZr[r\r]rrrrrKsrKc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_metaclass�	metaclasscCsf|�d�|�d�|�d�|�d�|�d�|�d�|�d�d}|�|�d	}|�|�dS)
Nzclass X(): passzclass X(object): passzclass X(object1, object2): passz(class X(object1, object2, object3): passzclass 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
        r$rXrrrrl]s







zTest_metaclass.test_unchangedcCs,d}d}|�||�d}d}|�||�dS)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!
        r:r;rrrrrszTest_metaclass.test_commentscCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d}|�||�d
}d}|�||�d}d
}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)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
        r:r;rrr�	test_meta�sBzTest_metaclass.test_metaN)r6r*r7r	rlrrPrrrrrNYsrNc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Test_getcwduZgetcwducCsTd}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)	Nz
os.getcwduz	os.getcwdzos.getcwdu()�os.getcwd()zmeth = os.getcwduzmeth = os.getcwdzos.getcwdu(args)zos.getcwd(args)r:r;rrrr>szTest_getcwdu.test_basiccCsd}d}|�||�dS)Nzos.getcwdu() # Foozos.getcwd() # Foor:r;rrrrjszTest_getcwdu.test_commentcCs.d}|�|�d}|�|�d}|�|�dS)NrRz	getcwdu()zos.getcwdb()r$rXrrrrls

zTest_getcwdu.test_unchangedcCsd}d}|�||�dS)Nz<
            if 1:
                os.getcwdu()
            z;
            if 1:
                os.getcwd()
            r:r;rrr�test_indentation"szTest_getcwdu.test_indentationcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nz
os .getcwdu()zos .getcwd()zos.  getcwduzos.  getcwdzos.getcwdu (  )zos.getcwd (  )r:r;rrr�test_multilation-szTest_getcwdu.test_multilationN)	r6r*r7r	r>rjrlrSrTrrrrrQ�s
rQc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�
Test_operator�operatorcCsd}d}|�||�dS)Nzoperator.isCallable(x)zcallable(x)r:r;rrr�test_operator_isCallable?sz&Test_operator.test_operator_isCallablecCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzoperator.sequenceIncludes(x, y)zoperator.contains(x, y)z operator .sequenceIncludes(x, y)zoperator .contains(x, y)z!operator.  sequenceIncludes(x, y)zoperator.  contains(x, y)r:r;rrr�test_operator_sequenceIncludesDsz,Test_operator.test_operator_sequenceIncludescCsd}d}|�||�dS)Nzoperator.isSequenceType(x)z>import collections.abc
isinstance(x, collections.abc.Sequence)r:r;rrr�test_operator_isSequenceTypeQsz*Test_operator.test_operator_isSequenceTypecCsd}d}|�||�dS)Nzoperator.isMappingType(x)z=import collections.abc
isinstance(x, collections.abc.Mapping)r:r;rrr�test_operator_isMappingTypeVsz)Test_operator.test_operator_isMappingTypecCsd}d}|�||�dS)Nzoperator.isNumberType(x)z,import numbers
isinstance(x, numbers.Number)r:r;rrr�test_operator_isNumberType[sz(Test_operator.test_operator_isNumberTypecCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzoperator.repeat(x, n)zoperator.mul(x, n)zoperator .repeat(x, n)zoperator .mul(x, n)zoperator.  repeat(x, n)zoperator.  mul(x, n)r:r;rrr�test_operator_repeat`sz"Test_operator.test_operator_repeatcCs@d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzoperator.irepeat(x, n)zoperator.imul(x, n)zoperator .irepeat(x, n)zoperator .imul(x, n)zoperator.  irepeat(x, n)zoperator.  imul(x, n)r:r;rrr�test_operator_irepeatmsz#Test_operator.test_operator_irepeatcCsd}d}|�||�dS)Nz
isCallable(x)z"You should use 'callable(x)' here.r��rrY�trrr�test_bare_isCallablezsz"Test_operator.test_bare_isCallablecCsd}d}|�||�dS)NzsequenceIncludes(x, y)z.You should use 'operator.contains(x, y)' here.r�r^rrr�test_bare_sequenceIncludessz(Test_operator.test_bare_sequenceIncludescCsd}d}|�||�dS)NzisSequenceType(z)z>You should use 'isinstance(z, collections.abc.Sequence)' here.r�r^rrr�!test_bare_operator_isSequenceType�sz/Test_operator.test_bare_operator_isSequenceTypecCsd}d}|�||�dS)NzisMappingType(x)z=You should use 'isinstance(x, collections.abc.Mapping)' here.r�r^rrr� test_bare_operator_isMappingType�sz.Test_operator.test_bare_operator_isMappingTypecCsd}d}|�||�dS)NzisNumberType(y)z4You should use 'isinstance(y, numbers.Number)' here.r�r^rrr�test_bare_operator_isNumberType�sz-Test_operator.test_bare_operator_isNumberTypecCsd}d}|�||�dS)Nzrepeat(x, n)z)You should use 'operator.mul(x, n)' here.r�r^rrr�test_bare_operator_repeat�sz'Test_operator.test_bare_operator_repeatcCsd}d}|�||�dS)Nzirepeat(y, 187)z,You should use 'operator.imul(y, 187)' here.r�r^rrr�test_bare_operator_irepeat�sz(Test_operator.test_bare_operator_irepeatN)r6r*r7r	rWrXrYrZr[r\r]r`rarbrcrdrerfrrrrrU;s


rUc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
Test_exitfuncZexitfunccCsd}d}|�||�dS)NzI
            import sys
            sys.exitfunc = my_atexit
            ze
            import sys
            import atexit
            atexit.register(my_atexit)
            r:r;rrrr��szTest_exitfunc.test_simplecCsd}d}|�||�dS)NzO
            import sys, crumbs
            sys.exitfunc = my_func
            zY
            import sys, crumbs, atexit
            atexit.register(my_func)
            r:r;rrr�test_names_import�szTest_exitfunc.test_names_importcCsd}d}|�||�dS)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)
            r:r;rrr�test_complex_expression�sz%Test_exitfunc.test_complex_expressioncCs,d}d}|�||�d}d}|�||�dS)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)
            r:r;rrrr�szTest_exitfunc.test_commentscCsd}d}|�||�dS)Nz]
            import sys
            def f():
                sys.exitfunc = func
            zz
            import sys
            import atexit
            def f():
                atexit.register(func)
             r:r;rrr�test_in_a_function�sz Test_exitfunc.test_in_a_functioncCsd}d}d}|�|||�dS)Nzsys.exitfunc = fzatexit.register(f)zKCan't find sys import; Please add an atexit import at the top of your file.r%)rr<r=�msgrrr�test_no_sys_import�sz Test_exitfunc.test_no_sys_importcCsd}|�|�dS)Nzf(sys.exitfunc)r$rXrrrrl�szTest_exitfunc.test_unchangedN)r6r*r7r	r�rhrirrjrlrlrrrrrg�srgc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_assertsZassertscCs:ddddddddd	d
ddg}|D]\}}|�||�q dS)
N)zself.assert_(True)�self.assertTrue(True))zself.assertEquals(2, 2)�self.assertEqual(2, 2))zself.assertNotEquals(2, 3)�self.assertNotEqual(2, 3))zself.assertAlmostEquals(2, 3)�self.assertAlmostEqual(2, 3))z self.assertNotAlmostEquals(2, 8)�self.assertNotAlmostEqual(2, 8))zself.failUnlessEqual(2, 2)ro)zself.failIfEqual(2, 3)rp)z self.failUnlessAlmostEqual(2, 3)rq)zself.failIfAlmostEqual(2, 8)rr)zself.failUnless(True)rn)zself.failUnlessRaises(foo)zself.assertRaises(foo))zself.failIf(False)zself.assertFalse(False)r:)rZtestsr<r=rrr�test_deprecated_names�s�z"Test_asserts.test_deprecated_namescCs�d}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�d	}d
}|�||�d}d}|�||�d
}d}|�||�dS)Nzeq = self.assertEqualszeq = 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") # foozself.assertEquals (2, 3)zself.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()r:r;rrr�
test_variantss*zTest_asserts.test_variantscCs|�d�|�d�dS)Nzself.assertEqualsOnSaturdayz!self.assertEqualsOnSaturday(3, 5)r$r�rrrrl#s
zTest_asserts.test_unchangedN)r6r*r7r	rsrtrlrrrrrm�srm)Br$r	rrVrrrrZ
lib2to3.testsrZTestCaserr8rArMrgrmrprur�r�r�r�r�r�r�r�r�r�rr
rr#r%r4r<r?rHrVr[rkrnr�r�r�r�r�r�r�r�r�r�r�r�rrrrrGrJrKrNrQrUrgrmrrrr�<module>s�9:;1#j3&}.&gH/+bn/< ]4B.Oh|P Z
=J%":&=cX

F1le Man4ger