Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_listcomps.cpython-312.opt-1.pyc

�

'Μg~]���ddlZddlZddlZddlZddlZddlmZdZGd�dej�Z	deiZ
d�Zedk(rej�yy)	�N)�
BrokenItera�
########### Tests borrowed from or inspired by test_genexps.py ############

Test simple loop with conditional

    >>> sum([i*i for i in range(100) if i&1 == 1])
    166650

Test simple nesting

    >>> [(i,j) for i in range(3) for j in range(4)]
    [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]

Test nesting with the inner expression dependent on the outer

    >>> [(i,j) for i in range(4) for j in range(i)]
    [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)]

Test the idiom for temporary variable assignment in comprehensions.

    >>> [j*j for i in range(4) for j in [i+1]]
    [1, 4, 9, 16]
    >>> [j*k for i in range(4) for j in [i+1] for k in [j+1]]
    [2, 6, 12, 20]
    >>> [j*k for i in range(4) for j, k in [(i+1, i+2)]]
    [2, 6, 12, 20]

Not assignment

    >>> [i*i for i in [*range(4)]]
    [0, 1, 4, 9]
    >>> [i*i for i in (*range(4),)]
    [0, 1, 4, 9]

Make sure the induction variable is not exposed

    >>> i = 20
    >>> sum([i*i for i in range(100)])
    328350

    >>> i
    20

Verify that syntax error's are raised for listcomps used as lvalues

    >>> [y for y in (1,2)] = 10          # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
       ...
    SyntaxError: ...

    >>> [y for y in (1,2)] += 10         # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
       ...
    SyntaxError: ...


########### Tests borrowed from or inspired by test_generators.py ############

Make a nested list comprehension that acts like range()

    >>> def frange(n):
    ...     return [i for i in range(n)]
    >>> frange(10)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Same again, only as a lambda expression instead of a function definition

    >>> lrange = lambda n:  [i for i in range(n)]
    >>> lrange(10)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Generators can call other generators:

    >>> def grange(n):
    ...     for x in [i for i in range(n)]:
    ...         yield x
    >>> list(grange(5))
    [0, 1, 2, 3, 4]


Make sure that None is a valid return value

    >>> [None for i in range(10)]
    [None, None, None, None, None, None, None, None, None, None]

c���eZdZddddefd�Zd�Zd�Zd�Z�fd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7d7�Z8d8�Z9d9�Z:d:�Z;d;�Z<d<�Z=d=�Z>d>�Z?�xZ@S)?�ListComprehensionTestN�c	��tj|�}|xsgd�}|D]�}|j|��5|dk(r=tjd�jtj|d���}d�}	nG|dk(r=tjd	�jtj|d���}d
�}	n|}d�}	|r|j�ni}
	|||
�|xsij
�D]\}}|j|	|
|�||��!	ddd���y#|$r%}
|jt|
�|�Yd}
~
�0d}
~
wwxYw#1swY��6xYw)N)�module�class�function)�scoper	zZ
                        class _C:
                            {code}
                    z    )�codec� �t|d|�S)N�_C)�getattr��moddict�names  �0/usr/local/lib/python3.12/test/test_listcomps.py�
get_outputz:ListComprehensionTest._check_in_scopes.<locals>.get_outputns��&�w�t�}�d�;�;�r
z�
                        def _f():
                            {code}
                            return locals()
                        _out = _f()
                    c��|d|S)N�_outrrs  rrz:ListComprehensionTest._check_in_scopes.<locals>.get_outputws��&�v��t�4�4rc��||S�Nrrs  rrz:ListComprehensionTest._check_in_scopes.<locals>.get_output{s��&�t�}�,r)
�textwrap�dedent�subTest�format�indent�copy�items�assertEqual�assertIs�type)�selfr�outputs�ns�scopes�raises�	exec_funcr�newcoder�newns�k�v�es              r�_check_in_scopesz&ListComprehensionTest._check_in_scopescsD�����t�$���:�:���E����E��*��G�#�&�o�o�/�� ��X�_�_�T�6�%B��C��<��j�(�&�o�o�/��
 ��X�_�_�T�6�%B��C��5�#�G�-�%'����	�R��E��g�u�-�
")��B� 5� 5� 7���1��(�(��E�1�)=�q�!�D�!8�9+�*���2�3��M�M�$�q�'�6�2�2��3��1+�*�s6�BE�	D�7E�E	�$E�?E�E	�	E�E	c�8�d}dgd�i}|j||�y)Nzf
            items = [(lambda i=i: i) for i in range(5)]
            y = [x() for x in items]
        �y)r�����r/�r$rr%s   r�*test_lambdas_with_iteration_var_as_defaultz@ListComprehensionTest.test_lambdas_with_iteration_var_as_default��%������(�����d�G�,rc�8�d}dgd�i}|j||�y)Nzb
            items = [(lambda: i) for i in range(5)]
            y = [x() for x in items]
        r1�r5r5r5r5r5r6r7s   r�test_lambdas_with_free_varz0ListComprehensionTest.test_lambdas_with_free_var�r9rc��Gd�d�}|j|jgd��|j|�j�|�y)Nc����eZdZ�fd�Zed�D���cgc]��fd���	c}}ZeD��cgc]	}|���c}}Z�xZScc}}wcc}}w)�JListComprehensionTest.test_class_scope_free_var_with_class_cell.<locals>.Cc���t��Sr)�super)r$�	__class__s �r�methodzQListComprehensionTest.test_class_scope_free_var_with_class_cell.<locals>.C.method�s����� � r�c����Srr)�is�r�<lambda>zSListComprehensionTest.test_class_scope_free_var_with_class_cell.<locals>.C.<lambda>�s���ar)�__name__�
__module__�__qualname__rC�ranger r1�
__classcell__)�.0rF�xrBs0p0@r�Cr?�s@���
!�+0��(�3�(�Q�i�(�3�E�#�$�e����e�$�A��4��$s
�A�A	rOr;)r!r1r"rC)r$rOs  r�)test_class_scope_free_var_with_class_cellz?ListComprehensionTest.test_class_scope_free_var_with_class_cell�s8��	%�	%�	
������o�.��
�
�a�c�j�j�l�A�&rc�>��d}|j|dtgi��y)Nz0
            res = [super for x in [1]]
        �res)r%)r/rA)r$rrBs  �r�test_references_superz+ListComprehensionTest.test_references_super�s&�����	
���d�U�U�G�,<��=rc�6�d}|j|t��y)Nz4
            res = [__class__ for x in [1]]
        �r(�r/�	NameError�r$rs  r�test_references___class__z/ListComprehensionTest.test_references___class__�s����	
���d�9��5rc�l�d}|j|ddgiddg��|j|tdg��y)	NzN
            __class__ = 2
            res = [__class__ for x in [1]]
        rRr3rr
)r%r'r	�r(r'rVrXs  r�!test_references___class___definedz7ListComprehensionTest.test_references___class___defined�sH����	
����u�q�c�l�H�j�3I�	�	K����d�9�g�Y��Grc�6�d}|j|t��y)Nz
            __class__ = 2
            class C:
                res = [__class__ for x in [1]]
            res = C.res
        rUrVrXs  r�#test_references___class___enclosingz9ListComprehensionTest.test_references___class___enclosing�s����	
���d�9��5rc�6�d}|j|t��y)NzO
            [super for _ in [1]]
            [__class__ for _ in [1]]
        rUrVrXs  r�*test_super_and_class_cell_in_sibling_compsz@ListComprehensionTest.test_super_and_class_cell_in_sibling_comps�s����	
���d�9��5rc�:�d}gd�dd�}|j||�y)Nzu
            items = [(lambda: i) for i in range(5)]
            i = 20
            y = [x() for x in items]
        r;�)r1rFr6r7s   r�test_inner_cell_shadows_outerz3ListComprehensionTest.test_inner_cell_shadows_outer�s%����
(�b�1�����d�G�,rc�:�d}ddgdd�}|j||�y)Nz�
            def f(x):
                return [lambda: x for x in range(x)], x
            fns, x = f(2)
            y = [fn() for fn in fns]
        r2r3�r1rNr6r7s   r�&test_inner_cell_shadows_outer_no_storez<ListComprehensionTest.test_inner_cell_shadows_outer_no_store�s)�����A��Q�'�����d�G�,rc�@�d}dgd�i}|j||ddg��y)Nzt
            items = [(lambda: y) for i in range(5)]
            y = 2
            z = [x() for x in items]
        �z)r3r3r3r3r3rr
�r'r6r7s   r�%test_closure_can_jump_over_comp_scopez;ListComprehensionTest.test_closure_can_jump_over_comp_scope�s/����
��(�����d�G�X�z�4J��Krc�>�d}ddgi}|j||ddg��y)Nz�
            def f():
                return [lambda: x for x in (x, [1])[1]]
            x = ...
            y = [fn() for fn in f()]
        r1r2rr
rir6r7s   r�test_cell_inner_free_outerz0ListComprehensionTest.test_cell_inner_free_outer�s0�������*�����d�G�X�z�4J��Krc�p�d}ddgi}|j||ddg��|j|dgt��y)	Nzj
            g = 2
            def f():
                return g
            y = [g for x in [1]]
        r1r3rr
rir	�r'r(rVr7s   r�test_free_inner_cell_outerz0ListComprehensionTest.test_free_inner_cell_outer�sG�������*�����d�G�X�z�4J��K����d�G�9�Y��Grc�:�d}dgd�d�}|j||�y)Nz�
            y = 10
            items = [(lambda: y) for y in range(5)]
            x = y
            y = 20
            out = [z() for z in items]
        �
r;)rN�outr6r7s   r�'test_inner_cell_shadows_outer_redefinedz=ListComprehensionTest.test_inner_cell_shadows_outer_redefined�s%�����?�3�����d�G�,rc�<�d}ddi}|j||ddi��y)Nzu
            def inner():
                return g
            [g for g in range(5)]
            x = inner()
        rN����g�r&r6r7s   r�test_shadows_outer_cellz-ListComprehensionTest.test_shadows_outer_cells-������)�����d�G��b�	��:rc�B�d}dddgd�}|j||ddi��y)Nzy
            global g
            x = g
            g = 2
            items = [g for g in [1]]
            y = g
        r2r3�rNr1r rvrwr6r7s   r�test_explicit_globalz*ListComprehensionTest.test_explicit_global
�2������Q�C�0�����d�G��a���9rc�B�d}dddgd�}|j||ddi��y)Nzy
            global g
            x = g
            g = 2
            items = [g for x in [1]]
            y = g
        r2r3rzrvrwr6r7s   r�test_explicit_global_2z,ListComprehensionTest.test_explicit_global_2r|rc�>�d}ddgi}|j||ddi��y)Nzr
            global g
            fns = [lambda: g for g in [2]]
            items = [fn() for fn in fns]
        r r3rvr2rwr6r7s   r�test_explicit_global_3z,ListComprehensionTest.test_explicit_global_3#s/����
�Q�C�.�����d�G��a���9rc�<�d}ddi}|j||ddg��y)NzK
            x = -1
            items = [(x:=y) for y in range(3)]
        rNr3rr
rir6r7s   r�test_assignment_expressionz0ListComprehensionTest.test_assignment_expression,s.������(�����d�G�X�z�4J��Krc�4�d}ddi}|j||�y)Nz�
            lst = range(3)
            funcs = [lambda: x for x in lst]
            inc = [x + 1 for x in lst]
            [x for x in inc]
            x = funcs[0]()
        rNr3r6r7s   r�test_free_var_in_comp_childz1ListComprehensionTest.test_free_var_in_comp_child5s$������(�����d�G�,rc�4�d}ddi}|j||�y)Nz�
            lst = range(3)
            x = -1
            funcs = [lambda: x for x in lst]
            items = [x + 1 for x in lst]
        rNrur6r7s   r�test_shadow_with_free_and_localz5ListComprehensionTest.test_shadow_with_free_and_local@�$������)�����d�G�,rc�6�d}ddgi}|j||�y)Nz<
            x = [1]
            y = [x for x in x]
        rNr2r6r7s   r�test_shadow_comp_iterable_namez4ListComprehensionTest.test_shadow_comp_iterable_nameJs&�������*�����d�G�,rc�<�d}ddi}|j||ddg��y)Nz
            x = 1
            def g():
                [x for x in range(3)]
                return x
            g()
        rNr2rr
rir6r7s   r�test_nested_freez&ListComprehensionTest.test_nested_freeRs.������(�����d�G�X�z�4J��Krc�4�d}ddi}|j||�y)Nzz
            import sys
            [i for i in range(2)]
            i = 20
            sys._getframe().f_locals
        rFrbr6r7s   r�test_introspecting_frame_localsz5ListComprehensionTest.test_introspecting_frame_locals]r�rc�@�d}dddggd�gi}|j||�y)NzX
            l = [2, 3]
            y = [[x ** 2 for x in range(x)] for x in l]
        r1rr2)rr2r5r6r7s   r�test_nestedz!ListComprehensionTest.test_nestedgs.�����!�Q���+�,�����d�G�,rc�r�d}dgd�i}|j||ddg��|j|dgt��y)	Nzt
            l = [1, 2, 3]
            x = 3
            y = [x for [x ** x for x in range(x)][x - 1] in l]
        r1)r4r4r4rr
rir	rnrVr7s   r�
test_nested_2z#ListComprehensionTest.test_nested_2osF����
�	�"�����d�G�X�z�4J��K����d�G�9�Y��Grc�8�d}dgd�i}|j||�y)Nzv
            l = [(1, 2), (3, 4), (5, 6)]
            y = [x for (x, [x ** x for x in range(x)][x - 1]) in l]
        r1)r2r4rDr6r7s   r�
test_nested_3z#ListComprehensionTest.test_nested_3ys%�����	�"�����d�G�,rc�R�d}dddgdfddgdfddgdfgi}|j||�y)Nz�
            items = [([lambda: x for x in range(2)], lambda: x) for x in range(3)]
            out = [([fn() for fn in fns], fn()) for fns, fn in items]
        rrr2r3r6r7s   r�
test_nested_4z#ListComprehensionTest.test_nested_4�sD�����Q��F�A�;�!�Q����q�!�f�a�[�A�B�����d�G�,rc�6�d}|j|t��y)Nz4
            [x for x in [1]]
            x
        rUrVrXs  r�test_nameerrorz$ListComprehensionTest.test_nameerror�s����
	
���d�9��5rc�6�d}ddgi}|j||�y)Nz.
            y = [__x for __x in [1]]
        r1r2r6r7s   r�test_dunder_namez&ListComprehensionTest.test_dunder_name�s&�������*�����d�G�,rc�l�d�}|jt�5|�ddd�y#1swYyxYw)Nc�2�	dD�cgc]}|��c}Scc}w)N)r2r)rNs r�fzGListComprehensionTest.test_unbound_local_after_comprehension.<locals>.f�s!������1�Q����H��
s�	��assertRaises�UnboundLocalError�r$r�s  r�&test_unbound_local_after_comprehensionz<ListComprehensionTest.test_unbound_local_after_comprehension�s)��	��
�
�0�
1�
�C�2�
1�
1���*�3c�l�d�}|jt�5|�ddd�y#1swYyxYw)Nc�D�dg}ddgfD�cgc]
\d<}d��c}Scc}w)Nr2r3rr)�ls rr�zHListComprehensionTest.test_unbound_local_inside_comprehension.<locals>.f�s/����A�)*�A��x�0�x�)�1�Q�4��A�x�0�0��0s�r�r�s  r�'test_unbound_local_inside_comprehensionz=ListComprehensionTest.test_unbound_local_inside_comprehension�s)��	1��
�
�0�
1�
�C�2�
1�
1�r�c�p�d}|j|ddiddiddg��|j|td	g�
�y)Nz�
            a = 1
            def f():
                func, = [(lambda: b) for b in [a]]
                return b, func()
            x = f()
        rN)r3r2�br3r
r�r&r'r	r[rVrXs  r�/test_global_outside_cellvar_inside_plus_freevarzEListComprehensionTest.test_global_outside_cellvar_inside_plus_freevar�sN����	
����3��-�S�!�H�j�(�5K�	�	M�	
���d�9�g�Y��Grc�p�d}|j|ddiddiddg��|j|td	g�
�y)Nz�
            a = 1
            def f():
                (func, inner_b), = [[lambda: b for b in c] + [b] for c in [[a]]]
                return b, inner_b, func()
            x = f()
        rN)r3r3r2r�r3r
rr�r	r[rVrXs  r�!test_cell_in_nested_comprehensionz7ListComprehensionTest.test_cell_in_nested_comprehension�sO����	
����3�	�"��Q�x��X�8N�	�	P�	
���d�9�g�Y��Grc�:�d}|j|tdg��y)NzA
            y = 1
            [x + y for x in range(2)]
        r	r[rVrXs  r�test_name_error_in_class_scopez4ListComprehensionTest.test_name_error_in_class_scope�s"����	
���d�9�g�Y��Grc�D�d}dddgi}|j||ddidg��y)	NzI
            y = 2
            vals = [(x, y) for x in range(2)]
        �vals�rr2�r2r2r1r2r	r�r6r7s   r�test_global_in_class_scopez0ListComprehensionTest.test_global_in_class_scope�s7�����F�F�+�,�����d�G��a��'���Krc�D�d}dddgi}|j||ddidg��y)	Nz�
            class C:
                y = 2
                vals = [(x, y) for x in range(2)]
            vals = C.vals
        r�r�r�r1r2r
r�r6r7s   r�%test_in_class_scope_inside_function_1z;ListComprehensionTest.test_in_class_scope_inside_function_1�s7�����F�F�+�,�����d�G��a��*���Nrc�>�d}dddgi}|j||dg��y)Nz�
            y = 1
            class C:
                y = 2
                vals = [(x, y) for x in range(2)]
            vals = C.vals
        r�r�r�r
rir6r7s   r�%test_in_class_scope_inside_function_2z;ListComprehensionTest.test_in_class_scope_inside_function_2�s1�����F�F�+�,�����d�G�Z�L��Arc�v�d}dddgi}|j||ddg��ddd	gi}|j||d
g��y)Na;
            y = 1
            class C:
                global y
                y = 2
                # Ensure the listcomp uses the global, not the value in the
                # class namespace
                locals()['y'] = 3
                vals = [(x, y) for x in range(2)]
            vals = C.vals
        r��rr3�r2r3rr	rir�r�r
r6r7s   r�test_in_class_scope_with_globalz5ListComprehensionTest.test_in_class_scope_with_global�sZ��
���F�F�+�,�����d�G�X�w�4G��H��F�F�+�,�����d�G�Z�L��Arc�>�d}dddgi}|j||dg��y)Na=
            y = 1
            class C:
                nonlocal y
                y = 2
                # Ensure the listcomp uses the global, not the value in the
                # class namespace
                locals()['y'] = 3
                vals = [(x, y) for x in range(2)]
            vals = C.vals
        r�r�r�r
rir6r7s   r�!test_in_class_scope_with_nonlocalz7ListComprehensionTest.test_in_class_scope_with_nonlocal�s1��
���F�F�+�,�����d�G�Z�L��Arc�<�d}ddgi}|j||dg��y)NzB
            items = [a for a in [1] if [a for _ in [0]]]
        r r2r	rir6r7s   r�test_nested_has_free_varz.ListComprehensionTest.test_nested_has_free_vars-�����Q�C�.�����d�G�W�I��>rc�n�d}|j|ddgiddg��|j|dgiddid	g�
�y)NzY
            z = 1
            items = [a for a in [1] if [x for x in [1] if z]]
        r r2rr
rirhrr	r�r6rXs  r�,test_nested_free_var_not_bound_in_outer_compzBListComprehensionTest.test_nested_free_var_not_bound_in_outer_compsL����	
���d�W�q�c�N�H�j�;Q��R����d�W�b�M�s�A�h��y��Qrc�2�d}|j|ddgi�y)Nz]
            items = [_C for _C in [1] for [0, 1][[x for x in [1] if _C][0]] in [2]]
        r r2r6rXs  r�test_nested_free_var_in_iterz2ListComprehensionTest.test_nested_free_var_in_iters!����	
���d�W�q�c�N�3rc�>�d}|j|ddgfddgfgi�y)NzM
            items = [(_C, [x for x in [1] if _C]) for _C in [0, 1]]
        r rr2r6rXs  r�test_nested_free_var_in_exprz2ListComprehensionTest.test_nested_free_var_in_exprs/����	
���d�W��2�w��Q�C��.A�$B�Crc�4�d}|j|ddgd��y)Nz�
            f = [(z, lambda y: [(x, y, z) for x in [3]]) for z in [1]]
            (z, func), = f
            out = func(2)
        r2)r4r3r2)rhrrr6rXs  r�test_nested_listcomp_in_lambdaz4ListComprehensionTest.test_nested_listcomp_in_lambda#s"����
	
���d�!�Y�K�$@�Arc�2�d}|j|ddd��y)Nz�
            (func, c), = [(a, b) for b in [1] for a in [lambda : a]]
            d = func()
            assert d is func
            # must use "a" in this scope
            e = a if False else None
        r2)�cr.r6rXs  r�test_lambda_in_iterz)ListComprehensionTest.test_lambda_in_iter+s ����	
���d�!�$�$7�8rc�8�d}|j|ddgidg��y)Nz*
            a = [1 for a in [0]]
        �ar2r
rir6rXs  r�.test_assign_to_comp_iter_var_in_outer_functionzDListComprehensionTest.test_assign_to_comp_iter_var_in_outer_function5s(����	
���d�S�1�#�J�
�|��Drc��d}|j|dgd�dg��|j|ddgd�dg��|j|tdg�	�y)
Nz�
            def b():
                [a for b in [1] for _ in []]
                return b, locals()
            r, s = b()
            x = r is b
            y = list(s.keys())
        T�rNr1rrir�r
r	r[rVrXs  r�test_no_leakage_to_localsz/ListComprehensionTest.test_no_leakage_to_locals;s\����	
���d�$�R�$8�(���L����d�$�c�U�$;�Z�L��Q����d�9�g�Y��Grc	�H�d}|j|ddgddgddgddgdd��y)NaJ
            l = [1, 2]
            y = 0
            items = [locals()["x"] for x in l]
            items2 = [vars()["x"] for x in l]
            items3 = [("x" in dir()) for x in l]
            items4 = [eval("x") for x in l]
            # x is available, and does not overwrite y
            [exec("y = x") for x in l]
        r2r3Tr)r �items2�items3�items4r1r6rXs  r�!test_iter_var_available_in_localsz7ListComprehensionTest.test_iter_var_available_in_localsHs@��	��	
�����Q���a�&���,��a�&��
�		
rc��d}|jd��}|j|dgdgdd��|jd��}|j|dgddgd�t��y)	Nz�
            value = ["ab"]
            result = snapshot = None
            try:
                result = [{func}(value) for value in value]
            except:
                snapshot = value
                raise
        �len��func�abr3��value�result�snapshot�intrU�rr/�
ValueError�r$�templaters   r�test_comp_in_try_exceptz-ListComprehensionTest.test_comp_in_try_except^sn�������E��*�����d�t�f���QU�$V�W����E��*�����d�t�f��SW�RX�$Y�%/�	�	1rc��d}|jd��}|j|dgdgdgd��|jd��}|j|dgddgd�t��y)	Nz�
            value = ["ab"]
            result = snapshot = None
            try:
                result = [{func}(value) for value in value]
            finally:
                snapshot = value
        r�r�r�r3r�r�rUr�r�s   r�test_comp_in_try_finallyz.ListComprehensionTest.test_comp_in_try_finallypsq�������E��*�����d�t�f���RV�QW�$X�Y����E��*�����d�t�f��SW�RX�$Y�%/�	�	1rc�4�d}|j|dddgi�y)Nz�
            value = [1, None]
            try:
                [v for v in value].sort()
            except:
                pass
        r�r2r6rXs  r� test_exception_in_post_comp_callz6ListComprehensionTest.test_exception_in_post_comp_call�s$����	
���d�W�q�$�i�$8�9rc�@�d}ddl}|j|ddid|i��y)NzK
            val = [sys._getframe().f_locals for a in [0]][0]["a"]
        r�val�sysrw)r�r/)r$rr�s   r�test_frame_localsz'ListComprehensionTest.test_frame_locals�s+����	����d�U�A�J�E�3�<��@rc���t|tj�s|S|jt	�fd�|j
D����S)Nc3�@�K�|]}�j|����y�wr)�_recursive_replace)rMr�r$s  �r�	<genexpr>z;ListComprehensionTest._recursive_replace.<locals>.<genexpr>�s!�����2
�0D�1�D�#�#�A�&�0D�s�)�	co_consts)�
isinstance�types�CodeType�replace�tupler�)r$�
maybe_codes` rr�z(ListComprehensionTest._recursive_replace�sG����*�e�n�n�5����!�!�E�2
�0:�0D�0D�2
�-
�!��	rc�X�t|dd�}|j|�}t||�y)Nz<string>�exec)�compiler�r�)r$�code_stringr&�cos    r�_replacing_execz%ListComprehensionTest._replacing_exec�s)��
�[�*�f�
5��
�
$�
$�R�
(���R��rc�x�d}|j|dgdd��|j|dgdd�|j��y)Nza
            x = 3
            [x for x in (1, 2)]
            dir()
            y = [x]
        r4re�r))r/r�rXs  r�test_code_replacez'ListComprehensionTest.test_code_replace�sD����	
���d�1�#�A�$6�7����d�1�#�A�$6�$�BV�BV��Wrc	�z�d}djd�t|�D��}djd�t|�D��}dtt|��it|�D�cic]}d|��|��
c}�}d|�d	|�d
|�d|�d�	}|j||�|j|||j�
�ycc}w)Ni,z; c3�,K�|]}d|�d|�����y�w)rNz = Nr�rMrFs  rr�zGListComprehensionTest.test_code_replace_extended_arg.<locals>.<genexpr>�s����H�7G�!�!�A�3�c�!��
�7G�s�z, c3�&K�|]	}d|�����y�w)rNNrrs  rr�zGListComprehensionTest.test_code_replace_extended_arg.<locals>.<genexpr>�s����@�/?�!��!��g�/?�s�r1rNz
            z
            [(z) for z6 in (range(300),)]
            dir()
            y = [z
]
        r�)�joinrK�listr/r�)r$�	num_names�assignments�	name_listrF�expectedrs       r�test_code_replace_extended_argz4ListComprehensionTest.test_code_replace_extended_arg�s����	��i�i�H�u�Y�7G�H�H���I�I�@�u�Y�/?�@�@�	���e�I�&�'�
�#(��#3�4�#3�a��1�#�w��z�#3�4�
��
�
�M���k��	�{�+���	�	��	
���d�H�-����d�H��8L�8L��M��5s�'
B8c��d}|j|ddgiddi��d}|j|ddgd�ddid	g�
�|j|ddgd�ddiddg�
�y)
NzG
            [x for x in [1]]
            y = [x for _ in [1]]
        r1r4rNrwzY
            x = 2
            [x for x in [1]]
            y = [x for _ in [1]]
        r3r�r	r�r
rr6rXs  r�&test_multiple_comprehension_name_reusez<ListComprehensionTest.test_multiple_comprehension_name_reuse�s����	
���d�S�1�#�J�C��8��<���
	
���d�!�1�#�$6�C��8�W�I��V����d�!�1�#�$6�C��8�Z�Ya�Lb��crc��d�}d�}d�}|df|df|dffD]�\}}|j|�5|�}tj|j�d}d}|j}	|j|j|	jd	z�|j|j|	jd	z�|j|j|j|z
|j|z
|�ddd���y#1swY��xYw)
Nc�t�	td��D�cgc]}|��c}ycc}w#t$r}|cYd}~Sd}~wwxYw)NT)�init_raises�r�	Exception�rNr.s  rrzCListComprehensionTest.test_exception_locations.<locals>.init_raises��8��
�&�4�8�9�8�q��8�9��9���
����
�� �"�	�"�"�	7�2�7�7c�t�	td��D�cgc]}|��c}ycc}w#t$r}|cYd}~Sd}~wwxYw)NT)�next_raisesrrs  rrzCListComprehensionTest.test_exception_locations.<locals>.next_raises�rrc�t�	td��D�cgc]}|��c}ycc}w#t$r}|cYd}~Sd}~wwxYw)NT)�iter_raisesrrs  rrzCListComprehensionTest.test_exception_locations.<locals>.iter_raises�rrzBrokenIter(init_raises=True)zBrokenIter(next_raises=True)zBrokenIter(iter_raises=True)r�r3)r�	traceback�
extract_tb�
__traceback__�__code__r!�lineno�co_firstlineno�
end_lineno�line�colno�	end_colno)
r$rrrr�r
�excr�rr�s
          r�test_exception_locationsz.ListComprehensionTest.test_exception_locations�s���	�	�	�!,�-K�L� +�-K�L� +�-K�L� �N�D�(����d�#��f���(�(��):�):�;�A�>�����]�]��� � ����2�+<�+<�q�+@�A�� � ����r�/@�/@�1�/D�E�� � �������&�(8�1�;�;��;O�!P�!)�+�$�#�	 �$�#�s�CC:�:D	)ArHrIrJr�r/r8r<rPrSrYr\r^r`rcrfrjrlrorsrxr{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�r�rrr
r&rL)rBs@rrrbsV���-1�d�4�PR�#'�"E�H-�-�	'�>�6�H�6�6�-�-�L�L�	H�	-�;�	:�	:�:�L�	-�-�-�	L�-�-�H�-�-�6�-���H�H�H�L�O�	B�B�"
B�?�R�4�D�B�9�E�H�
�,1�$1�":�A���
X�N�"
d�"+rr�doctestsc�L�|jtj��|Sr)�addTest�doctest�DocTestSuite)�loader�tests�patterns   r�
load_testsr/�s��	�M�M�'�&�&�(�)��Lr�__main__)r*rrr��unittest�test.supportrr'�TestCaser�__test__r/rH�mainrrr�<module>r6s`�������#�U��pH
+�H�-�-�H
+�T
��"���
�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists