HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/lib2to3/tests/__pycache__/test_fixers.cpython-310.pyc
o

�i��@s�dZddlZddlmZddlmZddlmZmZddl	m
Z
Gdd�de
j�ZGd	d
�d
e�Z
Gdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �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�ZGd/d0�d0e�Z Gd1d2�d2e�Z!Gd3d4�d4�Z"Gd5d6�d6ee"�Z#Gd7d8�d8ee"�Z$Gd9d:�d:ee"�Z%Gd;d<�d<e�Z&Gd=d>�d>e�Z'Gd?d@�d@e�Z(GdAdB�dBe�Z)GdCdD�dDe�Z*GdEdF�dFe�Z+GdGdH�dHe�Z,GdIdJ�dJe�Z-GdKdL�dLe�Z.GdMdN�dNe�Z/GdOdP�dPe�Z0GdQdR�dRe�Z1GdSdT�dTe�Z2GdUdV�dVe�Z3GdWdX�dXe�Z4GdYdZ�dZe�Z5Gd[d\�d\e�Z6Gd]d^�d^e�Z7Gd_d`�d`e�Z8Gdadb�dbe�Z9Gdcdd�dde�Z:Gdedf�dfe�Z;Gdgdh�dhe�Z<Gdidj�dje�Z=Gdkdl�dle�Z>Gdmdn�dne�Z?Gdodp�dpe�Z@Gdqdr�dre�ZAGdsdt�dte�ZBdS)uz" Test suite for the fixer modules �N)�chain)�
itemgetter)�pygram�
fixer_util)�supportc@sLeZdZddd�Zdd�Zddd	�Zdd
d�Zdd
�Zddd�Zdd�Z	dS)�
FixerTestCaseN�lib2to3cCsP|dur|jg}t�|||�|_g|_d|_t|jj|jj�D]}|j|_	qdS)Nz<string>)
�fixerr�get_refactorer�refactor�	fixer_log�filenamerZ	pre_orderZ
post_order�log)�selfZfix_listZ	fixer_pkg�optionsr	�r�6/usr/local/lib/python3.10/lib2to3/tests/test_fixers.py�setUps�
�zFixerTestCase.setUpcCs8t�|�}t�|�}|j�||j�}|�|t|��|S�N)rZreformatrZrefactor_stringr
�assertEqual�str)r�before�after�treerrr�_checks


zFixerTestCase._checkFcCs2|�||�}|�|j�|s|�|jg�dSdSr)r�
assertTrue�was_changedrr)rrr�ignore_warningsrrrr�check#s
�zFixerTestCase.checkcCs8|�||�}|�|d�|j��|s|�|j�dSdS)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�dSdSr)rrr)rrrrrrr"2s�zFixerTestCase.unchangedcGs�|jg}|�|�t�d|�}|��\}}d|j}|r'|djj�|�r'dS|r6|djj�|�r6|s6dS|�dd�	dd�||D��|f�dS)NrZfix_���z5Fixer run order (%s) is incorrect; %s should be last.�, cSsg|]}|jj�qSr)�	__class__�
__module__)�.0�xrrr�
<listcomp>D�z3FixerTestCase.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)
�__name__r*�__qualname__rrrr#r&r"r6rrrrr
s



rc@�(eZdZdZdd�Zdd�Zdd�ZdS)	�Test_ne�necC�d}d}|�||�dS)Nzif x <> y:
            passzif x != y:
            pass�r�r�b�arrr�
test_basicI�zTest_ne.test_basiccCr<)Nzif x<>y:
            passzif x!=y:
            passr=r>rrr�test_no_spacesQrBzTest_ne.test_no_spacescCr<)Nzif x<>y<>z:
            passzif x!=y!=z:
            passr=r>rrr�test_chainedYrBzTest_ne.test_chainedN)r7r*r8r	rArCrDrrrrr:Fs
r:c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�Test_has_keyZhas_keycCr<)Nz$x = d.has_key("x") or d.has_key("y")zx = "x" in d or "y" in dr=r>rrr�test_1d�zTest_has_key.test_1cCr<)Nzx = a.b.c.d.has_key("x") ** 3zx = ("x" in a.b.c.d) ** 3r=r>rrr�test_2irGzTest_has_key.test_2cCr<)Nz!x = a.b.has_key(1 + 2).__repr__()zx = (1 + 2 in a.b).__repr__()r=r>rrr�test_3nrGzTest_has_key.test_3cCr<)Nz,x = a.b.has_key(1 + 2).__repr__() ** -3 ** 4z(x = (1 + 2 in a.b).__repr__() ** -3 ** 4r=r>rrr�test_4srGzTest_has_key.test_4cCr<)Nzx = a.has_key(f or g)zx = (f or g) in ar=r>rrr�test_5xrGzTest_has_key.test_5cCr<)Nzx = a + b.has_key(c)zx = a + (c in b)r=r>rrr�test_6}rGzTest_has_key.test_6cCr<)Nzx = a.has_key(lambda: 12)zx = (lambda: 12) in ar=r>rrr�test_7�rGzTest_has_key.test_7cCr<)Nzx = a.has_key(a for a in b)zx = (a for a in b) in ar=r>rrr�test_8�rGzTest_has_key.test_8cCr<)Nzif not a.has_key(b): passzif b not in a: passr=r>rrr�test_9�rGzTest_has_key.test_9cCr<)Nz$if not a.has_key(b).__repr__(): passz if not (b in a).__repr__(): passr=r>rrr�test_10�rGzTest_has_key.test_10cCr<)Nzif not a.has_key(b) ** 2: passzif not (b in a) ** 2: passr=r>rrr�test_11�rGzTest_has_key.test_11N)r7r*r8r	rFrHrIrJrKrLrMrNrOrPrQrrrrrEasrEc@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_applyZapplycCr<)Nzx = apply(f, g + h)z
x = f(*g + h)r=r>rrrrF�rGzTest_apply.test_1cCr<)Nzy = apply(f, g, h)zy = f(*g, **h)r=r>rrrrH�rGzTest_apply.test_2cCr<)Nz z = apply(fs[0], g or h, h or g)zz = fs[0](*g or h, **h or g)r=r>rrrrI�rGzTest_apply.test_3cCr<)Nzapply(f, (x, y) + t)zf(*(x, y) + t)r=r>rrrrJ�rGzTest_apply.test_4cCr<)Nzapply(f, args,)�f(*args)r=r>rrrrK�rGzTest_apply.test_5cCr<)Nzapply(f, args, kwds,)�f(*args, **kwds)r=r>rrrrL�rGzTest_apply.test_6cCr<)Nzx = apply(f+g, args)zx = (f+g)(*args)r=r>rrr�test_complex_1�rGzTest_apply.test_complex_1cCr<)Nzx = apply(f*g, args)zx = (f*g)(*args)r=r>rrr�test_complex_2�rGzTest_apply.test_complex_2cCr<)Nzx = apply(f**g, args)zx = (f**g)(*args)r=r>rrr�test_complex_3�rGzTest_apply.test_complex_3cCr<)Nzx = apply(f.g, args)zx = f.g(*args)r=r>rrr�test_dotted_name�rGzTest_apply.test_dotted_namecCr<)Nzx = apply(f[x], args)zx = f[x](*args)r=r>rrr�test_subscript�rGzTest_apply.test_subscriptcCr<)Nzx = apply(f(), args)zx = f()(*args)r=r>rrr�	test_call�rGzTest_apply.test_callcCr<)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�rGzTest_apply.test_extremecCr<)Nz1apply(   # foo
          f, # bar
          args)rSr=r>rrr�test_weird_comments�szTest_apply.test_weird_commentscC�d}|�|�dS)Nzapply()r$�r�srrr�test_unchanged_1��zTest_apply.test_unchanged_1cCr])Nzapply(f)r$r^rrr�test_unchanged_2�razTest_apply.test_unchanged_2cCr])Nz	apply(f,)r$r^rrr�test_unchanged_3�razTest_apply.test_unchanged_3cCr])Nzapply(f, args, kwds, extras)r$r^rrr�test_unchanged_4�razTest_apply.test_unchanged_4cCr])Nzapply(f, *args, **kwds)r$r^rrr�test_unchanged_5�razTest_apply.test_unchanged_5cCr])Nzapply(f, *args)r$r^rrr�test_unchanged_6razTest_apply.test_unchanged_6cCr])Nzapply(f, **kwds)r$r^rrr�test_unchanged_6brazTest_apply.test_unchanged_6bcCr])Nz#apply(func=f, args=args, kwds=kwds)r$r^rrr�test_unchanged_7
razTest_apply.test_unchanged_7cCr])Nzapply(f, args=args, kwds=kwds)r$r^rrr�test_unchanged_8razTest_apply.test_unchanged_8cCr])Nzapply(f, args, kwds=kwds)r$r^rrr�test_unchanged_9razTest_apply.test_unchanged_9cCr<)Nzapply(  f,  args,   kwds)rTr=�rr@r?rrr�test_space_1rGzTest_apply.test_space_1cCr<)Nzapply(  f  ,args,kwds   )rTr=rkrrr�test_space_2rGzTest_apply.test_space_2N)r7r*r8r	rFrHrIrJrKrLrUrVrWrXrYrZr[r\r`rbrcrdrerfrgrhrirjrlrmrrrrrR�s8	rRc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Test_reload�reloadcCr<)Nz	reload(a)z$import importlib
importlib.reload(a)r=r>rrr�test#rGzTest_reload.testcC�,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_commentcC�@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_space2�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$r^rrr�test_unchanged?s$







zTest_reload.test_unchangedN)r7r*r8r	rqrsrurwrrrrro s

roc@r9)	�Test_intern�interncCrt)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_preservationcCrt)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>rrrrqmrvzTest_intern.testcC�Jd}|�|�d}|�|�d}|�|�d}|�|�d}|�|�dS)Nzintern(a=1)zintern(f, g)z
intern(*h)zintern(**i)zintern()r$r^rrrrw|�



zTest_intern.test_unchangedN)r7r*r8r	rzrqrwrrrrrx[s
rxc@rn)�Test_reduce�reducecCr<)Nzreduce(a, b, c)z,from functools import reduce
reduce(a, b, c)r=r>rrr�test_simple_call�rGzTest_reduce.test_simple_callcCr<)Nzdef x(arg): reduce(sum, [])z8from functools import reduce
def x(arg): reduce(sum, [])r=r>rrr�
test_bug_7253��zTest_reduce.test_bug_7253cCr<)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�rGz!Test_reduce.test_call_with_lambdacCr{)Nz	reduce(a)zreduce(a, b=42)zreduce(a, b, c, d)zreduce(**c)zreduce()r$r^rrrrw�r|zTest_reduce.test_unchangedN)r7r*r8r	rr�r�rwrrrrr}�sr}c@�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�printcCr<)Nzprint 1,   1+1,   1+1+1zprint(1,   1+1,   1+1+1)r=r>rrrrz�rGz#Test_print.test_prefix_preservationcC� d}|�|�d}|�|�dS)N�print()�	print('')r$r^rrr�test_idempotency�s
zTest_print.test_idempotencycCs:tj|jj_d}|�|�d}|�|�d}|�|�dS)N�print(1, 1+1, 1+1+1)r�r�)rZ!python_grammar_no_print_statementrZdriverZgrammarr"r^rrr�"test_idempotency_print_as_function�s

z-Test_print.test_idempotency_print_as_functioncCr<)Nzprint 1, 1+1, 1+1+1r�r=r>rrrrF�rGzTest_print.test_1cCr<)Nz
print 1, 2zprint(1, 2)r=r>rrrrH�rGzTest_print.test_2cCr<)Nr�r�r=r>rrrrI�rGzTest_print.test_3cCr<)Nzprint whatever; printzprint(whatever); print()r=r>rrrrJ�r�zTest_print.test_4cCr<)Nzprint; print whatever;zprint(); print(whatever);r=r>rrrrK�rGzTest_print.test_5cCr<)Nzprint (a, b, c)zprint((a, b, c))r=r>rrr�
test_tuple�rGzTest_print.test_tuplecCr<)Nzprint 1, 2, 3,zprint(1, 2, 3, end=' ')r=r>rrr�test_trailing_comma_1�rGz Test_print.test_trailing_comma_1cCr<)Nzprint 1, 2,zprint(1, 2, end=' ')r=r>rrr�test_trailing_comma_2�rGz Test_print.test_trailing_comma_2cCr<)Nzprint 1,zprint(1, end=' ')r=r>rrr�test_trailing_comma_3�rGz Test_print.test_trailing_comma_3cCr<)Nzprint >>sys.stderr, 1, 2, 3zprint(1, 2, 3, file=sys.stderr)r=r>rrr�!test_vargs_without_trailing_comma�rGz,Test_print.test_vargs_without_trailing_commacCr<)Nzprint >>sys.stderr, 1, 2,z%print(1, 2, end=' ', file=sys.stderr)r=r>rrr�test_with_trailing_commarGz#Test_print.test_with_trailing_commacCr<)Nzprint >>sys.stderr, 1+1zprint(1+1, file=sys.stderr)r=r>rrr�test_no_trailing_commarGz!Test_print.test_no_trailing_commacCr<)Nzprint >>  sys.stderrzprint(file=sys.stderr)r=r>rrr�test_spaces_before_file
rGz"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)rr_r?r@rrr�test_with_future_print_functions

z*Test_print.test_with_future_print_functionN)r7r*r8r	rzr�r�rFrHrIrJrKr�r�r�r�r�r�r�r�r�rrrrr��s&r�c@�`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�	Test_exec�execcCr<)Nz  exec code in ns1,   ns2z  exec(code, ns1,   ns2)r=r>rrrrzrGz"Test_exec.test_prefix_preservationcCr<)Nz	exec code�
exec(code)r=r>rrrrA!rGzTest_exec.test_basiccCr<)Nzexec code in ns�exec(code, ns)r=r>rrr�test_with_globals&rGzTest_exec.test_with_globalscCr<)Nzexec code in ns1, ns2�exec(code, ns1, ns2)r=r>rrr�test_with_globals_locals+rGz"Test_exec.test_with_globals_localscCr<)Nzexec (a.b()) in nszexec((a.b()), ns)r=r>rrrrU0rGzTest_exec.test_complex_1cCr<)Nzexec a.b() + c in nszexec(a.b() + c, ns)r=r>rrrrV5rGzTest_exec.test_complex_2cCr])Nr�r$r^rrrr`<razTest_exec.test_unchanged_1cCr])Nzexec (code)r$r^rrrrb@razTest_exec.test_unchanged_2cCr])Nr�r$r^rrrrcDrazTest_exec.test_unchanged_3cCr])Nr�r$r^rrrrdHrazTest_exec.test_unchanged_4N)r7r*r8r	rzrAr�r�rUrVr`rbrcrdrrrrr�sr�c@�HeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�	Test_repr�reprcCr<)Nz
x =   `1 + 2`zx =   repr(1 + 2)r=r>rrrrzOrGz"Test_repr.test_prefix_preservationcCr<)Nzx = `1 + 2`zx = repr(1 + 2)r=r>rrr�
test_simple_1TrGzTest_repr.test_simple_1cCr<)Nzy = `x`zy = repr(x)r=r>rrr�
test_simple_2YrGzTest_repr.test_simple_2cCr<)Nzz = `y`.__repr__()zz = repr(y).__repr__()r=r>rrr�test_complex^rGzTest_repr.test_complexcCr<)Nz
x = `1, 2, 3`zx = repr((1, 2, 3))r=r>rrrr�crGzTest_repr.test_tuplecCr<)Nz
x = `1 + `2``zx = repr(1 + repr(2))r=r>rrr�test_nestedhrGzTest_repr.test_nestedcCr<)Nzx = `1, 2 + `3, 4``zx = repr((1, 2 + repr((3, 4))))r=r>rrr�test_nested_tuplesmrGzTest_repr.test_nested_tuplesN)r7r*r8r	rzr�r�r�r�r�r�rrrrr�Ls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"S)#�Test_except�exceptcCr<)Nzq
            try:
                pass
            except (RuntimeError, ImportError),    e:
                passzs
            try:
                pass
            except (RuntimeError, ImportError) as    e:
                passr=r>rrrrzu�z$Test_except.test_prefix_preservationcCr<)NzV
            try:
                pass
            except Foo, e:
                pass�X
            try:
                pass
            except Foo as e:
                passr=r>rrr�test_simple�r�zTest_except.test_simplecCr<)NzU
            try:
                pass
            except Foo,e:
                passr�r=r>rrr�"test_simple_no_space_before_target�r�z.Test_except.test_simple_no_space_before_targetcCr<)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_unpackcCr<)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_classcCr<)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��zTest_except.test_list_unpackcCr<)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�r�zTest_except.test_weird_target_1cCr<)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�r�zTest_except.test_weird_target_2cCr<)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�r�zTest_except.test_weird_target_3cCr<)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_exceptcCr<)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_finallycCr<)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_exceptcC�Td}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_suitescCr])NzO
            try:
                pass
            except:
                passr$r^rrrr`m�zTest_except.test_unchanged_1cCr])NzY
            try:
                pass
            except Exception:
                passr$r^rrrrbur�zTest_except.test_unchanged_2cCr])Nzg
            try:
                pass
            except (Exception, SystemExit):
                passr$r^rrrrc}r�zTest_except.test_unchanged_3N)r7r*r8r	rzr�r�r�r�r�r�r�r�r�r�r�r�r`rbrcrrrrr�rs$


0r�c@r�)%�
Test_raise�raisecCr<)Nzraise Exception, 5�raise Exception(5)r=r>rrrrA�rGzTest_raise.test_basiccCrr)Nzraise Exception,5r�zraise   Exception,    5zraise   Exception(5)r=r>rrrrz��z#Test_raise.test_prefix_preservationcCrt)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_commentscCr<)Nzraise Exception(5), None, tbz%raise Exception(5).with_traceback(tb)r=r>rrr�test_None_value�rGzTest_raise.test_None_valuecCr<)Nzraise Exception, (5, 6, 7)zraise Exception(5, 6, 7)r=r>rrr�test_tuple_value�rGzTest_raise.test_tuple_valuecCr<)Nzraise E, (5, 6) % (a, b)zraise E((5, 6) % (a, b))r=r>rrr�test_tuple_detection�rGzTest_raise.test_tuple_detectioncCr<)Nzraise (((E1, E2), E3), E4), V�raise E1(V)r=r>rrr�test_tuple_exc_1�rGzTest_raise.test_tuple_exc_1cCr<)Nzraise (E1, (E2, E3), E4), Vr�r=r>rrr�test_tuple_exc_2�rGzTest_raise.test_tuple_exc_2cC�d}|�|d�dS)Nzraise 'foo'�+Python 3 does not support string exceptions�r&r^rrr�test_string_exc��zTest_raise.test_string_exccCr�)Nzraise "foo", 5r�r�r^rrr�test_string_exc_val�r�zTest_raise.test_string_exc_valcCr�)Nzraise "foo", 5, 6r�r�r^rrr�test_string_exc_val_tb�r�z!Test_raise.test_string_exc_val_tbcCr<)Nz4def foo():
                    raise Exception, 5, 6�Cdef foo():
                    raise Exception(5).with_traceback(6)r=r>rrr�	test_tb_1��zTest_raise.test_tb_1cCr<)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��zTest_raise.test_tb_2cCr<)Nz2def foo():
                    raise Exception,5,6r�r=r>rrr�	test_tb_3�r�zTest_raise.test_tb_3cCr<)Nzfdef foo():
                    a = 5
                    raise Exception,5,6
                    b = 6r�r=r>rrr�	test_tb_4�r�zTest_raise.test_tb_4cCr<)Nz<def foo():
                    raise Exception, (5, 6, 7), 6zIdef foo():
                    raise Exception(5, 6, 7).with_traceback(6)r=r>rrr�	test_tb_5�r�zTest_raise.test_tb_5cCr<)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�r�zTest_raise.test_tb_6N)r7r*r8r	rArzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s&	r�c@�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�throwcCr<)Nzg.throw(Exception, 5)�g.throw(Exception(5))r=r>rrrrFrGzTest_throw.test_1cCr<)Nzg.throw(Exception,5)r�r=r>rrrrHrGzTest_throw.test_2cCr<)Nzg.throw(Exception, (5, 6, 7))zg.throw(Exception(5, 6, 7))r=r>rrrrIrGzTest_throw.test_3cCr<)Nz5 + g.throw(Exception, 5)z5 + g.throw(Exception(5))r=r>rrrrJrGzTest_throw.test_4cCr�)Nzg.throw("foo")r�r�r^rrr�test_warn_1r�zTest_throw.test_warn_1cCr�)Nzg.throw("foo", 5)r�r�r^rrr�test_warn_2!r�zTest_throw.test_warn_2cCr�)Nzg.throw("foo", 5, 6)r�r�r^rrr�test_warn_3%r�zTest_throw.test_warn_3cCr])Nzg.throw(Exception)r$r^rrr�test_untouched_1+razTest_throw.test_untouched_1cCr])Nzg.throw(Exception(5, 6))r$r^rrr�test_untouched_2/razTest_throw.test_untouched_2cCr])Nz5 + g.throw(Exception(5, 6))r$r^rrr�test_untouched_33razTest_throw.test_untouched_3cCr<)Nz7def foo():
                    g.throw(Exception, 5, 6)�Fdef foo():
                    g.throw(Exception(5).with_traceback(6))r=r>rrrr�9r�zTest_throw.test_tb_1cCr<)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�@r�zTest_throw.test_tb_2cCr<)Nz5def foo():
                    g.throw(Exception,5,6)r�r=r>rrrr�Kr�zTest_throw.test_tb_3cCr<)Nzidef foo():
                    a = 5
                    g.throw(Exception,5,6)
                    b = 6r�r=r>rrrr�Rr�zTest_throw.test_tb_4cCr<)Nz?def foo():
                    g.throw(Exception, (5, 6, 7), 6)zLdef foo():
                    g.throw(Exception(5, 6, 7).with_traceback(6))r=r>rrrr�]r�zTest_throw.test_tb_5cCr<)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�dr�zTest_throw.test_tb_6cCr<)Nz;def foo():
                    a + g.throw(Exception, 5, 6)zJdef foo():
                    a + g.throw(Exception(5).with_traceback(6))r=r>rrr�	test_tb_7or�zTest_throw.test_tb_7cCr<)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_8vr�zTest_throw.test_tb_8N)r7r*r8r	rFrHrIrJr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s(r�c@�8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�	Test_long�longcCr<)Nzx = long(x)z
x = int(x)r=r>rrrrF�rGzTest_long.test_1cCr<)Nzy = isinstance(x, long)zy = isinstance(x, int)r=r>rrrrH�rGzTest_long.test_2cCr<)Nzz = type(x) in (int, long)zz = type(x) in (int, int)r=r>rrrrI�rGzTest_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$r^rrrrw�s





zTest_long.test_unchangedcCr<)Nzx =   long(  x  )zx =   int(  x  )r=r>rrrrz�rGz"Test_long.test_prefix_preservationN)	r7r*r8r	rFrHrIrwrzrrrrr��sr�c@� 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��$zTest_execfile.test_conversioncCrr)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�r�zTest_execfile.test_spacingN)r7r*r8r	r�r�rrrrr��sr�c@r9)	�Test_isinstance�
isinstancecCr�)	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��z*Test_isinstance.test_remove_multiple_itemscCr<)Nz4if    isinstance(  foo(), (  bar, bar, baz )) : passz/if    isinstance(  foo(), (  bar, baz )) : passr=r>rrrrz�rGz(Test_isinstance.test_prefix_preservationcC�|�d�dS)Nzisinstance(x, (str, int))r$�rrrrrw��zTest_isinstance.test_unchangedN)r7r*r8r	r�rzrwrrrrr��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&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>rrrrz�r�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�wrapperr_rrrrw*�


�zTest_dict.test_unchangedcCrr)N�d.keys()�list(d.keys())za[0].foo().keys()zlist(a[0].foo().keys())r=r>rrr�test_015r�zTest_dict.test_01cCr<)N�	d.items()zlist(d.items())r=r>rrr�test_02>rGzTest_dict.test_02cCr<)N�
d.values()zlist(d.values())r=r>rrr�test_03CrGzTest_dict.test_03cCr<)Nzd.iterkeys()�iter(d.keys())r=r>rrr�test_04HrGzTest_dict.test_04cCr<)Nz
d.iteritems()ziter(d.items())r=r>rrr�test_05MrGzTest_dict.test_05cCr<)Nzd.itervalues()ziter(d.values())r=r>rrr�test_06RrGzTest_dict.test_06cCr])Nr�r$r^rrr�test_07WrazTest_dict.test_07cCr])N�sorted(d.keys())r$r^rrr�test_08[razTest_dict.test_08cCr<)Nr�ziter(list(d.keys()))r=r>rrr�test_09_rGzTest_dict.test_09cCr<)Nz
foo(d.keys())zfoo(list(d.keys()))r=r>rrrrPdrGzTest_dict.test_10cCr<)N�for i in d.keys(): print iz for i in list(d.keys()): print ir=r>rrrrQirGzTest_dict.test_11cCr<)Nzfor i in d.iterkeys(): print irr=r>rrr�test_12nrGzTest_dict.test_12cCr<)N�[i for i in d.keys()]z for i in list(d.keys())]r=r>rrr�test_13srGzTest_dict.test_13cCr<)Nz[i for i in d.iterkeys()]r	r=r>rrr�test_14xrGzTest_dict.test_14cCr<)N�(i for i in d.keys())z(i for i in list(d.keys()))r=r>rrr�test_15}rGzTest_dict.test_15cCr<)Nz(i for i in d.iterkeys())rr=r>rrr�test_16�rGzTest_dict.test_16cCr<)Nziter(d.iterkeys())r�r=r>rrr�test_17�rGzTest_dict.test_17cCr<)Nzlist(d.iterkeys())r�r=r>rrr�test_18�rGzTest_dict.test_18cCr<)Nzsorted(d.iterkeys())rr=r>rrr�test_19�rGzTest_dict.test_19cCr<)Nzfoo(d.iterkeys())zfoo(iter(d.keys()))r=r>rrr�test_20�rGzTest_dict.test_20cCr<)Nzprint h.iterkeys().next()zprint iter(h.keys()).next()r=r>rrr�test_21�rGzTest_dict.test_21cCr<)Nzprint h.keys()[0]zprint list(h.keys())[0]r=r>rrr�test_22�rGzTest_dict.test_22cCr<)Nzprint list(h.iterkeys().next())z!print list(iter(h.keys()).next())r=r>rrr�test_23�rGzTest_dict.test_23cCr<)Nzfor x in h.keys()[0]: print xz#for x in list(h.keys())[0]: print xr=r>rrr�test_24�rGzTest_dict.test_24cCr<)Nzd.viewkeys()r�r=r>rrr�test_25�rGzTest_dict.test_25cCr<)Nz
d.viewitems()r�r=r>rrr�test_26�rGzTest_dict.test_26cCr<)Nzd.viewvalues()r�r=r>rrr�test_27�rGzTest_dict.test_27cCr<)Nz[i for i in d.viewkeys()]r	r=r>rrr�test_28�rGzTest_dict.test_28cCr<)Nz(i for i in d.viewkeys())rr=r>rrr�test_29�rGzTest_dict.test_29cCr<)Nziter(d.viewkeys())r�r=r>rrr�test_30�rGzTest_dict.test_30cCr<)Nzlist(d.viewkeys())r�r=r>rrr�test_31�rGzTest_dict.test_31cCr<)Nzsorted(d.viewkeys())rr=r>rrr�test_32�rGzTest_dict.test_32N)'r7r*r8r	rzr�rwr�r�r�rrrrrrrPrQrr
rr
rrrrrrrrrrrrrrrrrrrrrr��sJ	r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�Test_xrange�xrangecCrt)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>rrrrz�rvz$Test_xrange.test_prefix_preservationcCr<)Nzx = xrange(10)z
x = range(10)r=r>rrr�test_single_arg�rGzTest_xrange.test_single_argcCr<)Nzx = xrange(1, 10)zx = range(1, 10)r=r>rrr�
test_two_args�rGzTest_xrange.test_two_argscCr<)Nzx = xrange(0, 10, 2)zx = range(0, 10, 2)r=r>rrr�test_three_args�rGzTest_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_listcCrr)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_forr�zTest_xrange.test_xrange_in_forcC�|�d�|�d�dS)Nzfor i in range(10): passr%r$r�rrr�test_range_in_for�
zTest_xrange.test_range_in_forcCr�)Nzx in range(10, 3, 9)r$r�rrr�test_in_contains_testr�z!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)
r7r*r8r	rzr!r"r#r$r&r(r*r,rrrrr�s
	rc�$eZdZ�fdd�Zdd�Z�ZS)�Test_xrange_with_reducecstt|��ddg�dS)Nr r~)�superr.rr��r)rrr!szTest_xrange_with_reduce.setUpcCr<)Nzreduce(x, xrange(5))z0from functools import reduce
reduce(x, range(5))r=r>rrr�test_double_transform$�z-Test_xrange_with_reduce.test_double_transform)r7r*r8rr1�
__classcell__rrr0rr.sr.c@�PeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�Test_raw_inputZ	raw_inputcCrr)Nzx =    raw_input(   )zx =    input(   )zx = raw_input(   ''   )�x = input(   ''   )r=r>rrrrz-r�z'Test_raw_input.test_prefix_preservationcCr<)Nzx = raw_input()�x = input()r=r>rrrrF6rGzTest_raw_input.test_1cCr<)Nzx = raw_input('')�
x = input('')r=r>rrrrH;rGzTest_raw_input.test_2cCr<)Nzx = raw_input('prompt')�x = input('prompt')r=r>rrrrI@rGzTest_raw_input.test_3cCr<)Nzx = raw_input(foo(a) + 6)zx = input(foo(a) + 6)r=r>rrrrJErGzTest_raw_input.test_4cCr<)Nzx = raw_input(invite).split()zx = input(invite).split()r=r>rrrrKJrGzTest_raw_input.test_5cCr<)Nz x = raw_input(invite) . split ()zx = input(invite) . split ()r=r>rrrrLOrGzTest_raw_input.test_6cCr<)Nzx = int(raw_input())zx = int(input())r=r>rrrrNTrGzTest_raw_input.test_8N)r7r*r8r	rzrFrHrIrJrKrLrNrrrrr5*s	r5c@�(eZdZdZgd�Zdd�Zdd�ZdS)�Test_funcattrsZ	funcattrs)Zclosure�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@rrrrq^s
�zTest_funcattrs.testcC�F|jD]}d|}|�|�d|}|�|�d|}|�|�qdS)Nzfoo(func_%s + 5)�
f(foo.__%s__)�f(foo.__%s__.foo)�rDr"�rrFr_rrrrwhr�zTest_funcattrs.test_unchangedN�r7r*r8r	rDrqrwrrrrr;Ys

r;c@r9)	�Test_xreadlinesZ
xreadlinescCrt)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>rrrrZvrvzTest_xreadlines.test_callcCrt)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�rvzTest_xreadlines.test_attr_refcC�<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$r^rrrrw��


zTest_xreadlines.test_unchangedN)r7r*r8r	rZrNrwrrrrrMss


rMc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ImportsFixerTestscCsP|j��D] \}}d|}d|}|�||�d|}d|}|�||�qdS)N�	import %szimport foo, %s, bar��modules�itemsr�r�old�newr?r@rrr�test_import_module���z$ImportsFixerTests.test_import_modulecCsl|j��D].\}}d|}d|}|�||�d|}d|}|�||�d|}d|}|�||�qdS)Nzfrom %s import foozfrom %s import foo, barzfrom %s import (yes, no)rSrVrrr�test_import_from�s�z"ImportsFixerTests.test_import_fromcCsP|j��D] \}}d|}d|}|�||�d|}d|}|�||�qdS)Nzimport %s as foo_barrSrVrrr�test_import_module_as�rZz'ImportsFixerTests.test_import_module_ascC�4|j��D]\}}d|}d|}|�||�qdS)Nzfrom %s import foo as barrSrVrrr�test_import_from_as��
�z%ImportsFixerTests.test_import_from_ascCr])N�from %s import *rSrVrrr�	test_star�r_zImportsFixerTests.test_starcCs�|j��D]X\}}d||f}d||f}|�||�d||f}d||f}|�||�d|f}|�|�d|||f}d|||f}|�||�d||f}d||f}|�||�qdS)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
                )rTrUrr")rrWrXr?r@r_rrr�test_import_module_usage�sD�����
�����z*ImportsFixerTests.test_import_module_usageN)	r7r*r8rYr[r\r^rarbrrrrrQ�s

rQc@s,eZdZdZddlmZdd�Zdd�ZdS)	�Test_imports�imports���MAPPINGcCr<)Nzimport urlparse, cStringIOzimport urllib.parse, ior=r>rrr�test_multiple_importsrGz"Test_imports.test_multiple_importscCr<)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	r�z%Test_imports.test_multiple_imports_asN)	r7r*r8r	�fixes.fix_importsrgrTrhrirrrrrcs
rcc@seZdZdZddlmZdS)�
Test_imports2�imports2rerfN)r7r*r8r	�fixes.fix_imports2rgrTrrrrrksrkcr-)�Test_imports_fixer_ordercsRtt|��ddg�ddlm}|��|_ddlm}dD]	}|||j|<qdS)Nrdrlrerf)�dbhash�dumbdbm�dbm�gdbm)r/rnrrmrg�copyrTrj)rZmapping2Zmapping1�keyr0rrrs
�zTest_imports_fixer_order.setUpcCsdD]
}||_|�d�qdS)N)rdrl�import)r	r6)rZfixrrr�$test_after_local_imports_refactoring$s�z=Test_imports_fixer_order.test_after_local_imports_refactoring)r7r*r8rrvr3rrr0rrnsrnc@s\eZdZdZddlmZdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�Test_urllib�urllibrerfcCsD|j��D]\}}d|}dd�ttd�|��}|�||�qdS)NrRr(r)rTrUr �maprr)rrW�changesr?r@rrrrY.s
�zTest_urllib.test_import_modulec
Cs�|j��D]o\}}g}|D]M\}}|D]"}|�|�d||f}d||f}|�||�d|}	|�|	�qd|d�|�f}d|d�|�f}|�||�dd�|�}	|�|	�q
d|d�|�f}d�dd�|D��}|�||�qdS)N�from %s import %s�from foo import %sr(�
cSs"g|]
\}}d|d�|�f�qS)r{r()r )r+rX�membersrrrr-Js�z0Test_urllib.test_import_from.<locals>.<listcomp>)rTrU�appendrr"r )
rrWrzZall_membersrXr~�memberr?r@r_rrrr[4s*

��zTest_urllib.test_import_fromcC�$|jD]}d|}|�|d�qdS)Nzimport %s as fooz#This module is now multiple modules�rTr&�rrWr_rrrr\N�
�z!Test_urllib.test_import_module_ascCs||j��D]6\}}|D]/\}}|D](}d||f}d||f}|�||�d|||f}d|||f}|�||�qqqdS)N�from %s import %s as foo_barzfrom %s import %s as blah, %srS)rrWrzrXr~r�r?r@rrrr^Ss���zTest_urllib.test_import_from_ascCr�)Nr`zCannot handle star importsr�r�rrrra^r�zTest_urllib.test_starcCrr)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_indentedcCr<)Nzfrom urllib import getproxiesz%from urllib.request import getproxiesr=r>rrr�test_single_import|r2zTest_urllib.test_single_importc		Cs�|j��D]I\}}|D]B\}}|D];}d�dd�|j|D��}d|||f}d|||f}|�||�d|||||f}d|||||f}|�||�qqqdS)Nr(cSsg|]\}}|�qSrr)r+r5Zmemsrrrr-�r.z8Test_urllib.test_import_module_usage.<locals>.<listcomp>z^
                        import %s
                        foo(%s.%s)
                        z`
                        import %s
                        %s.%s(%s.%s)
                        )rTrUr r)	rrWrzrXr~r�Z
new_importr?r@rrrrb�s.
��������z$Test_urllib.test_import_module_usageN)r7r*r8r	Zfixes.fix_urllibrgrTrYr[r\r^rar�r�rbrrrrrw*srwc@r�)�
Test_input�inputcCrr)Nzx =   input(   )zx =   eval(input(   ))r6zx = eval(input(   ''   ))r=r>rrrrz�r�z#Test_input.test_prefix_preservationcCr<)Nzx = input()  #  foozx = eval(input())  #  foor=r>rrrr��rGz Test_input.test_trailing_commentcC�.d}|�|�d}|�|�d}|�|�dS)N�x = eval(input())�x = eval(input(''))�x = eval(input(foo(5) + 9))r$r^rrrr���

zTest_input.test_idempotencycCr<)Nr7r�r=r>rrrrF�rGzTest_input.test_1cCr<)Nr8r�r=r>rrrrH�rGzTest_input.test_2cCr<)Nr9zx = eval(input('prompt'))r=r>rrrrI�rGzTest_input.test_3cCr<)Nzx = input(foo(5) + 9)r�r=r>rrrrJ�rGzTest_input.test_4N)r7r*r8r	rzr�r�rFrHrIrJrrrrr��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&d'�Zd(d)�Zd*S)+�Test_tuple_paramsZtuple_paramscCr])Nzdef foo(): passr$r^rrrr`�raz"Test_tuple_params.test_unchanged_1cCr])Nzdef foo(a, b, c): passr$r^rrrrb�raz"Test_tuple_params.test_unchanged_2cCr])Nzdef foo(a=3, b=4, c=5): passr$r^rrrrc�raz"Test_tuple_params.test_unchanged_3cCr<)Nz8
            def foo(((a, b), c)):
                x = 5zn
            def foo(xxx_todo_changeme):
                ((a, b), c) = xxx_todo_changeme
                x = 5r=r>rrrrF�r�zTest_tuple_params.test_1cCr<)Nz;
            def foo(((a, b), c), d):
                x = 5zq
            def foo(xxx_todo_changeme, d):
                ((a, b), c) = xxx_todo_changeme
                x = 5r=r>rrrrH�r�zTest_tuple_params.test_2cCr<)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>rrrrI�r�zTest_tuple_params.test_3cCr<)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�rBz Test_tuple_params.test_semicoloncCr<)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_keywordsr�zTest_tuple_params.test_keywordscCr<)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_varargsr�zTest_tuple_params.test_varargscCr<)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_1�zTest_tuple_params.test_multi_1cCr<)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%r�zTest_tuple_params.test_multi_2cCr<)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_docstring1�z Test_tuple_params.test_docstringcCr])N�lambda x: x + 5r$r^rrr�test_lambda_no_change?raz'Test_tuple_params.test_lambda_no_changecC�Td}d}|�||�d}d}|�||�d}d}|�||�d}d}|�||�dS)Nzlambda (x): x + 5r�zlambda(x): x + 5zlambda ((((x)))): x + 5zlambda((((x)))): x + 5r=r>rrr�test_lambda_parens_single_argCr�z/Test_tuple_params.test_lambda_parens_single_argcCr�)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_simpleTr�z$Test_tuple_params.test_lambda_simplecC�,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_tupleer�z'Test_tuple_params.test_lambda_one_tuplecCr<)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_usenrGz.Test_tuple_params.test_lambda_simple_multi_usecCr<)Nzlambda (x, y): y + xzlambda x_y: x_y[1] + x_y[0]r=r>rrr�test_lambda_simple_reversesrGz,Test_tuple_params.test_lambda_simple_reversecCr�)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_nestedxr�z$Test_tuple_params.test_lambda_nestedcCr<)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�rGz.Test_tuple_params.test_lambda_nested_multi_useN)r7r*r8r	r`rbrcrFrHrIr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s,		r�c@r:)�Test_methodattrsZmethodattrs)�funcr�classcCsd|jD],}d|}|dkrd}nd|}|�||�d|}|dkr%d}nd|}|�||�qdS)Nza.im_%sr�za.__self__.__class__rAzself.foo.im_%s.foo_barz#self.foo.__self__.__class__.foo_barrBrCrErrrrq�s
�zTest_methodattrs.testcCrG)Nzfoo(im_%s + 5)rHrIrJrKrrrrw�r�zTest_methodattrs.test_unchangedNrLrrrrr��s
r�c@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�nextcCr<)Nz	it.next()znext(it)r=r>rrrrF�rGzTest_next.test_1cCr<)Nza.b.c.d.next()z
next(a.b.c.d)r=r>rrrrH�rGzTest_next.test_2cCr<)Nz(a + b).next()z
next((a + b))r=r>rrrrI�rGzTest_next.test_3cCr<)Nz
a().next()z	next(a())r=r>rrrrJ�rGzTest_next.test_4cCr<)Nza().next() + bz
next(a()) + br=r>rrrrK�rGzTest_next.test_5cCr<)Nzc(      a().next() + b)zc(      next(a()) + b)r=r>rrrrL�rGzTest_next.test_6cCr<)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�r�z$Test_next.test_prefix_preservation_1cCr<)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�r�z$Test_next.test_prefix_preservation_2cC�d}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��z$Test_next.test_prefix_preservation_3cCr�)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�r=r>rrr�test_prefix_preservation_4�sz$Test_next.test_prefix_preservation_4cCr�)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�r=r>rrr�test_prefix_preservation_5	r�z$Test_next.test_prefix_preservation_5cCr<)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	r�z$Test_next.test_prefix_preservation_6cCr<)Nz[
            class A:
                def next(self):
                    pass
            z_
            class A:
                def __next__(self):
                    pass
            r=r>rrr�
test_method_1	r�zTest_next.test_method_1cCr<)Nzc
            class A(object):
                def next(self):
                    pass
            zg
            class A(object):
                def __next__(self):
                    pass
            r=r>rrr�
test_method_2,	r�zTest_next.test_method_2cCr<)NzX
            class A:
                def next(x):
                    pass
            z\
            class A:
                def __next__(x):
                    pass
            r=r>rrr�
test_method_39	r�zTest_next.test_method_3cCr<)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_4F	szTest_next.test_method_4cCr])Nza
            class A:
                def next(self, a, b):
                    pass
            r$r^rrr�test_method_unchanged_	r�zTest_next.test_method_unchangedcCr�)Nzy
            next = foo

            class A:
                def next(self, a, b):
                    pass
            �)Calls to builtin next() possibly shadowedr�r^rrr�test_shadowing_assign_simpleg	�z&Test_next.test_shadowing_assign_simplecCr�)Nz~
            (next, a) = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_assign_tuple_1q	r�z'Test_next.test_shadowing_assign_tuple_1cCr�)Nz�
            (a, (b, (next, c)), a) = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_assign_tuple_2{	r�z'Test_next.test_shadowing_assign_tuple_2cCr�)Nz~
            [next, a] = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_assign_list_1�	r�z&Test_next.test_shadowing_assign_list_1cCr�)Nz�
            [a, [b, [next, c]], a] = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_assign_list_2�	r�z&Test_next.test_shadowing_assign_list_2cCr�)Nz�
            def foo():
                __builtin__.next = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_builtin_assign�	�zTest_next.test_builtin_assigncCr�)Nz�
            def foo():
                (a, __builtin__.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_builtin_assign_in_tuple�	r�z&Test_next.test_builtin_assign_in_tuplecCr�)Nz�
            def foo():
                [a, __builtin__.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_builtin_assign_in_list�	r�z%Test_next.test_builtin_assign_in_listcCr])Nz�
            def foo():
                A.next = foo

            class A:
                def next(self, a, b):
                    pass
            r$r^rrr�test_assign_to_next�	�zTest_next.test_assign_to_nextcCr])Nz�
            def foo():
                (a, A.next) = foo

            class A:
                def next(self, a, b):
                    pass
            r$r^rrr�test_assign_to_next_in_tuple�	r�z&Test_next.test_assign_to_next_in_tuplecCr])Nz�
            def foo():
                [a, A.next] = foo

            class A:
                def next(self, a, b):
                    pass
            r$r^rrr�test_assign_to_next_in_list�	r�z%Test_next.test_assign_to_next_in_listcCr�)Nz�
            import foo.bar as next

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_1�	r�z!Test_next.test_shadowing_import_1cCr�)Nz�
            import bar, bar.foo as next

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_2�	r�z!Test_next.test_shadowing_import_2cCr�)Nz�
            import bar, bar.foo as next, baz

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_3�	r�z!Test_next.test_shadowing_import_3cCr�)Nz�
            from x import next

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_from_1�	r�z&Test_next.test_shadowing_import_from_1cCr�)Nz�
            from x.a import next

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_from_2
r�z&Test_next.test_shadowing_import_from_2cCr�)Nz�
            from x import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_from_3
r�z&Test_next.test_shadowing_import_from_3cCr�)Nz�
            from x.a import a, next, b

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_import_from_4
r�z&Test_next.test_shadowing_import_from_4cCr�)Nz�
            def next(a):
                pass

            class A:
                def next(self, a, b):
                    pass
            r�r�r^rrr�test_shadowing_funcdef_1!
r�z"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_2cCr�)NzW
            def f():
                global next
                next = 5
            r�r�r^rrr�test_shadowing_global_1C
�z!Test_next.test_shadowing_global_1cCr�)Nz]
            def f():
                global a, next, b
                next = 5
            r�r�r^rrr�test_shadowing_global_2K
r�z!Test_next.test_shadowing_global_2cCr�)Nze
            for next in it():
                pass

            b = 5
            c = 6
            r�r�r^rrr�test_shadowing_for_simpleS
r�z#Test_next.test_shadowing_for_simplecCr�)Nzh
            for next, b in it():
                pass

            b = 5
            c = 6
            r�r�r^rrr�test_shadowing_for_tuple_1]
r�z$Test_next.test_shadowing_for_tuple_1cCr�)Nzp
            for a, (next, c), b in it():
                pass

            b = 5
            c = 6
            r�r�r^rrr�test_shadowing_for_tuple_2g
r�z$Test_next.test_shadowing_for_tuple_2cCr<)Nzgnext = g.nextzgnext = g.__next__r=r>rrr�test_noncall_access_1q
rGzTest_next.test_noncall_access_1cCr<)Nz
f(g.next + 5)zf(g.__next__ + 5)r=r>rrr�test_noncall_access_2v
rGzTest_next.test_noncall_access_2cCr<)Nzf(g().next + 5)zf(g().__next__ + 5)r=r>rrr�test_noncall_access_3{
rGzTest_next.test_noncall_access_3N)1r7r*r8r	rFrHrIrJrKrLr�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�r�r�r�r�r�r�rrrrr��s^



















r�c@r�)
�Test_nonzero�nonzerocCr<)Nzb
            class A:
                def __nonzero__(self):
                    pass
            z_
            class A:
                def __bool__(self):
                    pass
            r=r>rrrrF�
r�zTest_nonzero.test_1cCr<)Nzj
            class A(object):
                def __nonzero__(self):
                    pass
            �g
            class A(object):
                def __bool__(self):
                    pass
            r=r>rrrrH�
r�zTest_nonzero.test_2cCr])Nr�r$r^rrrr`�
r�zTest_nonzero.test_unchanged_1cCr])Nzm
            class A(object):
                def __nonzero__(self, a):
                    pass
            r$r^rrrrb�
r�zTest_nonzero.test_unchanged_2cCr])NzE
            def __nonzero__(self):
                pass
            r$r^rrr�test_unchanged_func�
sz Test_nonzero.test_unchanged_funcN)	r7r*r8r	rFrHr`rbr�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_numliteralsZnumliteralscCr<)NZ0755�0o755r=r>rrr�test_octal_1�
rGzTest_numliterals.test_octal_1cCr<)Nza = 12L�a = 12r=r>rrr�test_long_int_1�
rGz Test_numliterals.test_long_int_1cCr<)Nza = 12lr�r=r>rrr�test_long_int_2�
rGz Test_numliterals.test_long_int_2cCr<)Nz	b = 0x12lzb = 0x12r=r>rrr�
test_long_hex�
rGzTest_numliterals.test_long_hexcCrr)Nzb =   0x12Lz
b =   0x12zb = 0755 # spamzb = 0o755 # spamr=r>rrr�test_comments_and_spacing�
r�z*Test_numliterals.test_comments_and_spacingcCr])N�5r$r^rrr�test_unchanged_int�
raz#Test_numliterals.test_unchanged_intcCr])Nz5.0r$r^rrr�test_unchanged_float�
raz%Test_numliterals.test_unchanged_floatcCr])Nr�r$r^rrr�test_unchanged_octal�
raz%Test_numliterals.test_unchanged_octalcCr])NZ0xABCr$r^rrr�test_unchanged_hex�
raz#Test_numliterals.test_unchanged_hexcCr])Nz5.0e10r$r^rrr�test_unchanged_exp�
raz#Test_numliterals.test_unchanged_expcCr])Nz5 + 4jr$r^rrr�test_unchanged_complex_int�
raz+Test_numliterals.test_unchanged_complex_intcCr])Nz
5.4 + 4.9jr$r^rrr�test_unchanged_complex_float�
raz-Test_numliterals.test_unchanged_complex_floatcCr�)NZ4jz4.4jr$r^rrr�test_unchanged_complex_bare�
s
z,Test_numliterals.test_unchanged_complex_bareN)r7r*r8r	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]!\}\}}d||f}d||f}|�||�d|}|�|�qdS)Nr{r|)�listrTrUrr")r�modrWrXr?r@r_rrrr[�
s�zTest_renames.test_import_fromcCsDt|j���D]\}\}}d||f}d||f}|�||�qdS)Nr��r�rTrUr�rr�rWrXr?r@rrrr^s
�z Test_renames.test_import_from_ascCsLt|j���D]\}\}}d||||f}d||||f}|�||�qdS)NzJ
                import %s
                foo(%s, %s.%s)
                r�r�rrrrbs
�
��z%Test_renames.test_import_module_usagecCsLt|j���D]\}\}}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)	r7r*r8r	rTr[r^rbr�rrrrr��
s	r�c@r�)�Test_unicode�unicodecCrt)Nzunicode( x)zstr( x)z unicode(x )z str(x )z u'h'z 'h'r=r>rrr�test_whitespace'rvzTest_unicode.test_whitespacecCr<)Nzunicode(x, y, z)zstr(x, y, z)r=r>rrr�test_unicode_call4rGzTest_unicode.test_unicode_callcCr<)Nzunichr(u'h')zchr('h')r=r>rrr�test_unichr9rGzTest_unicode.test_unichrcCr<)Nzu"x"z"x"r=r>rrr�test_unicode_literal_1>rGz#Test_unicode.test_unicode_literal_1cCr<)Nzur'x'zr'x'r=r>rrr�test_unicode_literal_2CrGz#Test_unicode.test_unicode_literal_2cCr<)Nz
UR'''x''' z	R'''x''' r=r>rrr�test_unicode_literal_3HrGz#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_uMr�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_uVr�z(Test_unicode.test_bytes_literal_escape_ucCrr)Nzu'\\\u20ac\U0001d121\\u20ac'r�zur'\\\u20ac\U0001d121\\u20ac'r�r=r>rrr�test_unicode_literal_escape_u_r�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_uhsz1Test_unicode.test_native_unicode_literal_escape_uN)r7r*r8r	r�r�r�r�r�r�r�rrrrrrrr�$s
			r�c@r�)
�Test_filter�filtercCrr)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>rrrrzvr�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_basics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_trailerscC�d}|�|�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��L

















z Test_filter.test_filter_nochangecC�4d}|�|�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�rkrrr�test_future_builtins��
z Test_filter.test_future_builtinsN)	r7r*r8r	rzrrr
r
rrrrrss	(rcsXeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Z�ZS)�Test_mapryc�&|�d||�tt|��||�dS)Nz!from future_builtins import map; )r"r/rrr>r0rrr��zTest_map.checkcCr<)Nzx =    map(   f,    'abc'   )z#x =    list(map(   f,    'abc'   ))r=r>rrrrz�rGz!Test_map.test_prefix_preservationcCr�)	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�r�zTest_map.test_map_trailerscCr<)Nzx = map(f, 'abc')   #   fooz!x = list(map(f, 'abc'))   #   foor=r>rrrr��rGzTest_map.test_trailing_commentcCr�)Nzx = map(None, a, b, c)z5cannot convert map(None, ...) with multiple argumentsr�r^rrr�!test_None_with_multiple_arguments�r�z*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_basiccCr)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$rzTest_map.test_map_nochangecCr)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�rkrrrr
LrzTest_map.test_future_builtins)
r7r*r8r	rrzrr�rrrr
r3rrr0rr�s"(rcs@eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Z�Z	S)�Test_zip�zipcr)Nz!from future_builtins import zip; )r"r/rrr>r0rrrZrzTest_zip.checkcCrt)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_basic^rvzTest_zip.test_zip_basiccCrr)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_trailerskr�zTest_zip.test_zip_trailerscCr)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_nochangetrzTest_zip.test_zip_nochangecCr)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�rkrrrr
�rzTest_zip.test_future_builtins)
r7r*r8r	rrrrr
r3rrr0rrWs
	(rc@�eZdZdZdd�ZdS)�Test_standarderrorZ
standarderrorcCrt)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>rrrrq�rvzTest_standarderror.testN)r7r*r8r	rqrrrrr��rc@r)�
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)r7r*r8r	r"rrrrr�rrc@r�)'�Test_idiomsZidiomscCrt)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_whilecCrO)Nzwhile 11: foo()zwhile 0: foo()zwhile foo(): foo()zwhile []: foo()r$r^rrr�test_while_unchanged�rPz Test_idioms.test_while_unchangedcCrr)Nztype(x) == T�isinstance(x, T)zif   type(x) == T: pass�if   isinstance(x, T): passr=r>rrr�test_eq_simple�r�zTest_idioms.test_eq_simplecCrr)NzT == type(x)r&zif   T == type(x): passr'r=r>rrr�test_eq_reverse
r�zTest_idioms.test_eq_reversecCrr)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
r�zTest_idioms.test_eq_expressioncCrr)Nztype(x) is Tr&zif   type(x) is T: passr'r=r>rrr�test_is_simple
r�zTest_idioms.test_is_simplecCrr)NzT is type(x)r&zif   T is type(x): passr'r=r>rrr�test_is_reverse
r�zTest_idioms.test_is_reversecCrr)Nztype(x+y) is d.get('T')r*ztype(   x  +  y) is d.get('T')r+r=r>rrr�test_is_expression'
r�zTest_idioms.test_is_expressioncCrr)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_simple0
r�zTest_idioms.test_is_not_simplecCrr)NzT is not type(x)r0zif   T is not type(x): passr1r=r>rrr�test_is_not_reverse9
r�zTest_idioms.test_is_not_reversecCrr)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_expressionB
r�z"Test_idioms.test_is_not_expressioncCrr)Nztype(x) != Tr0zif   type(x) != T: passr1r=r>rrr�test_ne_simpleK
r�zTest_idioms.test_ne_simplecCrr)NzT != type(x)r0zif   T != type(x): passr1r=r>rrr�test_ne_reverseT
r�zTest_idioms.test_ne_reversecCrr)Nztype(x+y) != d.get('T')r4ztype(   x  +  y) != d.get('T')r5r=r>rrr�test_ne_expression]
r�zTest_idioms.test_ne_expressioncCr])Nztype(x).__name__r$r	rrr�test_type_unchangedf
razTest_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_callj
s0zTest_idioms.test_sort_list_callcC�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_exprcCr�)NzM
            v = list(t)
            w.sort()
            foo(w)
            zN
            v = list(t)
            v.sort(u)
            foo(v)
            r$r^rrr�test_sort_unchanged s
zTest_idioms.test_sort_unchangedN)r7r*r8r	r$r%r(r)r,r-r.r/r2r3r6r7r8r9r:r?rArBrrrrr#�s(
												dRr#c@r)�Test_basestring�
basestringcCr<)Nzisinstance(x, basestring)zisinstance(x, str)r=r>rrr�test_basestring2rGzTest_basestring.test_basestringN)r7r*r8r	rErrrrrC/rrCc@r�)�Test_buffer�buffercCr<)Nz
x = buffer(y)zx = memoryview(y)r=r>rrr�test_buffer:rGzTest_buffer.test_buffercCr<)Nzbuffer(y)[4:5]zmemoryview(y)[4:5]r=r>rrr�test_slicing?rGzTest_buffer.test_slicingN)r7r*r8r	rHrIrrrrrF7srFc@r�)�Test_future�futurecCrt)Nzfrom __future__ import bracesrz'# comment
from __future__ import bracesz
# comment
z'from __future__ import braces
# commentz

# commentr=r>rrr�test_futureGrvzTest_future.test_futurecCr�)Nr��r6r�rrr�test_run_orderTr�zTest_future.test_run_orderN)r7r*r8r	rLrNrrrrrJDs
rJc@r4)�Test_itertools�	itertoolscCs<dD]}dD]}||d|}||}|�||�qqdS)N)z
itertools.r)ryrr�ir=)rrrrQrr?r@rrr�checkallZs��zTest_itertools.checkallcCr<)Nzitertools.izip(a, b)z	zip(a, b)r=r>rrr�test_0dszTest_itertools.test_0cC�d}d}|�||�dS)Nz%s(f, a)�rRr>rrrrFkrGzTest_itertools.test_1cCrr)Nzitertools.ifilterfalse(a, b)zitertools.filterfalse(a, b)zitertools.izip_longest(a, b)zitertools.zip_longest(a, b)r=r>rrr�test_qualifiedpr�zTest_itertools.test_qualifiedcCrr)Nzifilterfalse(a, b)zfilterfalse(a, b)zizip_longest(a, b)zzip_longest(a, b)r=r>rrrrHyr�zTest_itertools.test_2cCrT)Nz    %s(f, a)rUr>rrrrl�rGzTest_itertools.test_space_1cCrr)Nz     itertools.ifilterfalse(a, b)z    itertools.filterfalse(a, b)z     itertools.izip_longest(a, b)z    itertools.zip_longest(a, b)r=r>rrrrm�r�zTest_itertools.test_space_2cCs|�ddd�dS)NryrrrMr�rrrrN�szTest_itertools.test_run_orderN)r7r*r8r	rRrSrFrVrHrlrmrNrrrrrOWs
			rOc@r�)�Test_itertools_importsZitertools_importscCrt)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�rvz#Test_itertools_imports.test_reducedcCr<)Nz%#foo
from itertools import imap, izipz#foo
r=r>rrr�
test_comments�rGz$Test_itertools_imports.test_commentscCr�)Nz from itertools import imap, iziprzfrom itertools import izipr=r>rrr�	test_none�r�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@r_rrr�test_import_as�sz%Test_itertools_imports.test_import_ascCsndD]2}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=)rr=r?r@rrr�test_ifilter_and_zip_longest�s





�z3Test_itertools_imports.test_ifilter_and_zip_longestcCr])Nzfrom itertools import *r$r^rrr�test_import_star�raz'Test_itertools_imports.test_import_starcCr])NrXr$r^rrrrw�raz%Test_itertools_imports.test_unchangedN)r7r*r8r	rYrZr[r\r_r`rwrrrrrW�s
	rWcs�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_importrucsDtt����g�_t��_d�_�fdd�}ddlm}||_	dS)NTcs�j�|��jp
|�jvSr)�
files_checkedr�
always_exists�
present_files�r=r�rr�fake_exists�sz&Test_import.setUp.<locals>.fake_existsr��
fix_import)
r/rarrb�setrdrc�
lib2to3.fixesrh�exists)rrfrhr0r�rr�s
zTest_import.setUpcCsddlm}tjj|_dS)Nrrg)rjrh�os�pathrk)rrhrrr�tearDown�szTest_import.tearDowncs2d|_tt|��||�d|_tt|��|�dS)NTF)rcr/rarr"r>r0rr�
check_both�szTest_import.check_bothcs�dd�}d|_tdg�|_dtjjdddd	f}|d
�d|d�f}|D]7�g|_�|_|�d
�tj�	��r>tj�	��d�nd�t�fdd�|D��}|�
d�|�t|j�|�q"dS)NcSstjj�|�d��S)N�/)rlrm�pathsepr �split)rmrrr�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+�extrerr�	<genexpr>s�z1Test_import.test_files_checked.<locals>.<genexpr>)rcrirdrlrm�seprbr
r"�dirname�addr)rrsZexpected_extensionsZ
names_to_testZexpected_checksrrer�test_files_checked�s 

�zTest_import.test_files_checkedcCs$d}d|_tdg�|_|�|�dS)N�
import barF�bar.py�rcrirdr"r^rrr�test_not_in_packageszTest_import.test_not_in_packagecCs&d}d|_tddg�|_|�|�dS)Nz1from __future__ import absolute_import
import barFrtr|r}r^rrr�!test_with_absolute_import_enabledsz-Test_import.test_with_absolute_import_enabledcCs,d}d}d|_tddg�|_|�||�dS)Nr{�from . import barFrtr|)rcrirdrr>rrr�test_in_packages
zTest_import.test_in_packagecCs4d}d}d|_tddtjjg�|_|�||�dS)Nr{r�FrtZbar)rcrirlrmrwrdrr>rrr�test_import_from_package$s
z$Test_import.test_import_from_packagecCr])Nr�r$r^rrr�test_already_relative_import+raz(Test_import.test_already_relative_importcCr<)Nzimport bar # Foozfrom . import bar # Foor=r>rrr�test_comments_and_indent/rGz$Test_import.test_comments_and_indentcCrt)Nzfrom foo import bar, bazzfrom .foo import bar, bazzfrom foo import barzfrom .foo import barzfrom foo import (bar, baz)zfrom .foo import (bar, baz)�ror>rrr�	test_from4rvzTest_import.test_fromcCr<)Nzfrom green.eggs import hamzfrom .green.eggs import hamr�r>rrr�test_dotted_fromArGzTest_import.test_dotted_fromcCr<)Nz"from green.eggs import ham as spamz#from .green.eggs import ham as spamr�r>rrr�test_from_asFrGzTest_import.test_from_ascCr�)	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_importKr�zTest_import.test_importcCrr)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>rrrr\\r�zTest_import.test_import_ascCs(d|_tddg�|_d}|�|d�dS)NFzfoo.pyrtr�z#absolute and local imports together)rcrirdr&r^rrr�test_local_and_absoluteesz#Test_import.test_local_and_absolutecCr<)Nzimport foo.barzfrom . import foo.barr�r>rrr�test_dotted_importlrGzTest_import.test_dotted_importcCr<)Nzimport foo.bar as bangzfrom . import foo.bar as bangr�r>rrr�test_dotted_import_asqrGz!Test_import.test_dotted_import_ascCr<)Nz1
        # prefix
        import foo.bar
        z8
        # prefix
        from . import foo.bar
        r�r>rrr�test_prefixvr�zTest_import.test_prefix)r7r*r8r	rrnrorzr~rr�r�r�r�r�r�r�r�r\r�r�r�r�r3rrr0rra�s*
	rac@r�)
�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>rrrrA�s2zTest_set_literal.test_basiccCr�)	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�r�zTest_set_literal.test_listcompscCr@)Nzset( [1, 2])z{1, 2}z
set([1 ,  2])z{1 ,  2}z
set([ 1 ])z{ 1 }z
set( [1] )r�zset([  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_whitespacecCrr)Nzset((1, 2)) # Hiz{1, 2} # HizZ
            # Foo
            set( # Bar
               (1, 2)
            )
            z2
            # Foo
            {1, 2}
            r=r>rrrrZ�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$r^rrrrw�s




zTest_set_literal.test_unchangedN)	r7r*r8r	rAr�r�rZrwrrrrr��s# r�c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�Test_sys_excZsys_exccCr<)Nzsys.exc_typezsys.exc_info()[0]r=r>rrrrSrGzTest_sys_exc.test_0cCr<)Nz
sys.exc_valuezsys.exc_info()[1]r=r>rrrrF	rGzTest_sys_exc.test_1cCr<)Nzsys.exc_tracebackzsys.exc_info()[2]r=r>rrrrHrGzTest_sys_exc.test_2cCr<)Nzsys.exc_type # Foozsys.exc_info()[0] # Foor=r>rrrrIrGzTest_sys_exc.test_3cCr<)Nzsys.  exc_typezsys.  exc_info()[0]r=r>rrrrJrGzTest_sys_exc.test_4cCr<)Nzsys  .exc_typezsys  .exc_info()[0]r=r>rrrrKrGzTest_sys_exc.test_5N)
r7r*r8r	rSrFrHrIrJrKrrrrr�sr�c@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
Test_parenZparencCr<)Nz[i for i in 1, 2 ]z[i for i in (1, 2) ]r=r>rrrrS&rGzTest_paren.test_0cCr<)Nz[i for i in 1, 2, ]z[i for i in (1, 2,) ]r=r>rrrrF+rGzTest_paren.test_1cCr<)Nz[i for i  in     1, 2 ]z[i for i  in     (1, 2) ]r=r>rrrrH0rGzTest_paren.test_2cCr<)Nz[i for i in 1, 2 if i]z[i for i in (1, 2) if i]r=r>rrrrI5rGzTest_paren.test_3cCr<)Nz[i for i in 1,    2    ]z[i for i in (1,    2)    ]r=r>rrrrJ:rGzTest_paren.test_4cCr<)Nz(i for i in 1, 2)�(i for i in (1, 2))r=r>rrrrK?rGzTest_paren.test_5cCr<)Nz(i for i in 1   ,2   if i)z(i for i in (1   ,2)   if i)r=r>rrrrLDrGzTest_paren.test_6cCr])Nz[i for i in (1, 2)]r$r^rrr�test_unchanged_0IrazTest_paren.test_unchanged_0cCr])Nz[i for i in foo()]r$r^rrrr`MrazTest_paren.test_unchanged_1cCr])Nz[i for i in (1, 2) if nothing]r$r^rrrrbQrazTest_paren.test_unchanged_2cCr])Nr�r$r^rrrrcUrazTest_paren.test_unchanged_3cCr])Nz[i for i in m]r$r^rrrrdYrazTest_paren.test_unchanged_4N)r7r*r8r	rSrFrHrIrJrKrLr�r`rbrcrdrrrrr�#sr�c@r9)	�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$r^rrrrwas







zTest_metaclass.test_unchangedcCrr)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>rrrrZvs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)r7r*r8r	rwrZr�rrrrr�]s
r�c@r�)
�Test_getcwduZgetcwducCr�)	Nz
os.getcwduz	os.getcwdzos.getcwdu()�os.getcwd()zmeth = os.getcwduzmeth = os.getcwdzos.getcwdu(args)zos.getcwd(args)r=r>rrrrAr�zTest_getcwdu.test_basiccCr<)Nzos.getcwdu() # Foozos.getcwd() # Foor=r>rrrrsrGzTest_getcwdu.test_commentcCr�)Nr�z	getcwdu()zos.getcwdb()r$r^rrrrwr�zTest_getcwdu.test_unchangedcCr<)Nz<
            if 1:
                os.getcwdu()
            z;
            if 1:
                os.getcwd()
            r=r>rrr�test_indentation&r�zTest_getcwdu.test_indentationcCrt)Nz
os .getcwdu()zos .getcwd()zos.  getcwduzos.  getcwdzos.getcwdu (  )zos.getcwd (  )r=r>rrr�test_multilation1rvzTest_getcwdu.test_multilationN)	r7r*r8r	rArsrwr�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�ZdS)�
Test_operator�operatorcCr<)Nzoperator.isCallable(x)zcallable(x)r=r>rrr�test_operator_isCallableCrGz&Test_operator.test_operator_isCallablecCrt)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_sequenceIncludesHrvz,Test_operator.test_operator_sequenceIncludescCr<)Nzoperator.isSequenceType(x)z>import collections.abc
isinstance(x, collections.abc.Sequence)r=r>rrr�test_operator_isSequenceTypeUrGz*Test_operator.test_operator_isSequenceTypecCr<)Nzoperator.isMappingType(x)z=import collections.abc
isinstance(x, collections.abc.Mapping)r=r>rrr�test_operator_isMappingTypeZrGz)Test_operator.test_operator_isMappingTypecCr<)Nzoperator.isNumberType(x)z,import numbers
isinstance(x, numbers.Number)r=r>rrr�test_operator_isNumberType_rGz(Test_operator.test_operator_isNumberTypecCrt)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_repeatdrvz"Test_operator.test_operator_repeatcCrt)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_irepeatqrvz#Test_operator.test_operator_irepeatcCr<)Nz
isCallable(x)z"You should use 'callable(x)' here.r��rr_�trrr�test_bare_isCallable~rGz"Test_operator.test_bare_isCallablecCr<)NzsequenceIncludes(x, y)z.You should use 'operator.contains(x, y)' here.r�r�rrr�test_bare_sequenceIncludes�rGz(Test_operator.test_bare_sequenceIncludescCr<)NzisSequenceType(z)z>You should use 'isinstance(z, collections.abc.Sequence)' here.r�r�rrr�!test_bare_operator_isSequenceType�rGz/Test_operator.test_bare_operator_isSequenceTypecCr<)NzisMappingType(x)z=You should use 'isinstance(x, collections.abc.Mapping)' here.r�r�rrr� test_bare_operator_isMappingType�rGz.Test_operator.test_bare_operator_isMappingTypecCr<)NzisNumberType(y)z4You should use 'isinstance(y, numbers.Number)' here.r�r�rrr�test_bare_operator_isNumberType�rGz-Test_operator.test_bare_operator_isNumberTypecCr<)Nzrepeat(x, n)z)You should use 'operator.mul(x, n)' here.r�r�rrr�test_bare_operator_repeat�rGz'Test_operator.test_bare_operator_repeatcCr<)Nzirepeat(y, 187)z,You should use 'operator.imul(y, 187)' here.r�r�rrr�test_bare_operator_irepeat�rGz(Test_operator.test_bare_operator_irepeatN)r7r*r8r	r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�?s 


r�c@r�)�
Test_exitfuncZexitfunccCr<)NzI
            import sys
            sys.exitfunc = my_atexit
            ze
            import sys
            import atexit
            atexit.register(my_atexit)
            r=r>rrrr��r�zTest_exitfunc.test_simplecCr<)NzO
            import sys, crumbs
            sys.exitfunc = my_func
            zY
            import sys, crumbs, atexit
            atexit.register(my_func)
            r=r>rrr�test_names_import�r�zTest_exitfunc.test_names_importcCr<)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�r�z%Test_exitfunc.test_complex_expressioncCrr)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>rrrrZ�szTest_exitfunc.test_commentscCr<)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�r�z 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_importcCr])Nzf(sys.exitfunc)r$r^rrrrw�razTest_exitfunc.test_unchangedN)r7r*r8r	r�r�r�rZr�r�rwrrrrr��sr�c@r9)	�Test_assertsZassertscCs&gd�}|D]
\}}|�||�qdS)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)r�)zself.failIfEqual(2, 3)r�)z self.failUnlessAlmostEqual(2, 3)r�)zself.failIfAlmostEqual(2, 8)r�)zself.failUnless(True)r�)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_namescCr@)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_variantss*zTest_asserts.test_variantscCr')Nzself.assertEqualsOnSaturdayz!self.assertEqualsOnSaturday(3, 5)r$r�rrrrw'r)zTest_asserts.test_unchangedN)r7r*r8r	r�r�rwrrrrr��s
r�)C�__doc__rlrPrr�rrrrZ
lib2to3.testsrZTestCaserr:rErRrorxr}r�r�r�r�r�r�r�r�r�r�rr.r5r;rMrQrcrkrnrwr�r�r�r�r�r�r�r�rrrrrr#rCrFrJrOrWrar�r�r�r�r�r�r�r�rrrr�<module>s�9:;1#j3&}.&gH/+br/< ]4B.Oh|P Z
=J%":&=cX