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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_parser.cpython-38.opt-1.pyc
U

>��g��@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�dej
�ZGdd�dej
�ZGdd	�d	ej
�Z
Gd
d�dej
�ZGdd
�d
ej
�ZGdd�dej
�Zedkr�e��dS)�N)�support)�assert_python_failurec@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�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/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dES)F�RoundtripLegalSyntaxTestCasec
Csl||�}|��}zt�|�}Wn6tjk
rT}z|�d||f�W5d}~XYnX|�||��d�dS)Nzcould not roundtrip %r: %sz!could not re-generate syntax tree)�totuple�parser�sequence2st�ParserError�fail�assertEqual)�self�f�s�st1�t�st2�why�r�//opt/cppython/lib/python3.8/test/test_parser.py�	roundtrips$�z&RoundtripLegalSyntaxTestCase.roundtripcCs|�tj|�dS�N)rr�expr�rr
rrr�
check_exprsz'RoundtripLegalSyntaxTestCase.check_exprcCs6t�d�}|��}i}t|i|�|�|dt�dS)Nz/from __future__ import unicode_literals; x = ''�x)r�suite�compile�execZassertIsInstance�str)rr�codeZscoperrr�test_flags_passed s

z.RoundtripLegalSyntaxTestCase.test_flags_passedcCs|�tj|�dSr)rrrrrrr�check_suite)sz(RoundtripLegalSyntaxTestCase.check_suitecCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�dS)Nzdef f(): yield 1zdef f(): yieldzdef f(): x += yieldzdef f(): x = yield 1zdef f(): x = y = yield 1zdef f(): x = yieldzdef f(): x = y = yieldzdef f(): 1 + (yield)*2zdef f(): (yield 1)*2zdef f(): return; yield 1zdef f(): yield 1; returnzdef f(): yield from 1zdef f(): x = yield from 1zdef f(): f((yield from 1))zdef f(): yield 1; return 1z1def f():
    for x in range(30):
        yield x
z)def f():
    if (yield):
        yield x
�r �rrrr�test_yield_statement,s"















z1RoundtripLegalSyntaxTestCase.test_yield_statementcCs@|�d�|�d�|�d�|�d�|�d�|�d�dS)Nzasync def f():
 await smth()z"async def f():
 foo = await smth()z'async def f():
 foo, bar = await smth()zasync def f():
 (await smth())z#async def f():
 foo((await smth()))z&async def f():
 await foo(); return 42r!r"rrr�test_await_statementCs




z1RoundtripLegalSyntaxTestCase.test_await_statementcCs|�d�|�d�dS)Nz"async def f():
 async with 1: passz/async def f():
 async with a as b, c as d: passr!r"rrr�test_async_with_statementKs
z6RoundtripLegalSyntaxTestCase.test_async_with_statementcCs|�d�|�d�dS)Nz'async def f():
 async for i in (): passz*async def f():
 async for i, b in (): passr!r"rrr�test_async_for_statementOs
z5RoundtripLegalSyntaxTestCase.test_async_for_statementcCs|�d�|�d�dS)Nz3def f():
    x = 0
    def g():
        nonlocal x
z:def f():
    x = y = 0
    def g():
        nonlocal x, y
r!r"rrr�test_nonlocal_statementSs
z4RoundtripLegalSyntaxTestCase.test_nonlocal_statementcCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d �|�d!�|�d"�|�d#�|�d$�|�d%�|�d&�|�d'�|�d(�|�d)�dS)*Nzfoo(1)z	[1, 2, 3]z[x**3 for x in range(20)]z"[x**3 for x in range(20) if x % 3]z+[x**3 for x in range(20) if x % 2 if x % 3]�list(x**3 for x in range(20))z&list(x**3 for x in range(20) if x % 3)z/list(x**3 for x in range(20) if x % 2 if x % 3)z
foo(*args)zfoo(*args, **kw)z	foo(**kw)zfoo(key=value)zfoo(key=value, *args)zfoo(key=value, *args, **kw)zfoo(key=value, **kw)zfoo(a, b, c, *args)zfoo(a, b, c, *args, **kw)zfoo(a, b, c, **kw)zfoo(a, *args, keyword=23)z	foo + barz	foo - barz	foo * barz	foo / barz
foo // barz
(foo := 1)z	lambda: 0zlambda x: 0zlambda *y: 0zlambda *y, **z: 0z
lambda **z: 0zlambda x, y: 0zlambda foo=bar: 0z"lambda foo=bar, spaz=nifty+spit: 0zlambda foo=bar, **z: 0z#lambda foo=bar, blaz=blat+2, **z: 0z'lambda foo=bar, blaz=blat+2, *y, **z: 0zlambda x, *y, **z: 0z(x for x in range(10))zfoo(x for x in range(10))z...za[...]�rr"rrr�test_expressions]sR







































z-RoundtripLegalSyntaxTestCase.test_expressionscCs|�d�dS)N�ar!r"rrr�test_simple_expression�sz3RoundtripLegalSyntaxTestCase.test_simple_expressioncCs|�d�|�d�dS)Nza = bza = b = c = d = er!r"rrr�test_simple_assignments�s
z4RoundtripLegalSyntaxTestCase.test_simple_assignmentsc	Cs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��td
ii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRX|�t��tdii�W5QRXdS)Nz
x: int = 5z"y: List[T] = []; z: [list] = fun()zx: tuple = (1, 2)zd[f()]: int = 42zf(d[x]): str = 'abc'zx.y.z.w: complex = 42jzx: intz#def f():
    x: str
    y: int = 5
z#class C:
    x: str
    y: int = 5
zIclass C:
    def __init__(self, x: int) -> None:
        self.x: int = x
z2+2: intz[]: int = 5zx, *y, z: int = range(5)zx: int = 1, y = 2z
u = v: intz
False: intzx.False: intz	x.y,: intz[0]: intzf(): int)r �assertRaises�SyntaxErrorrr"rrr�test_var_annot�s<









z+RoundtripLegalSyntaxTestCase.test_var_annotcCs||�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�dS)
Nza += bza -= bza *= bza /= bza //= bza %= bza &= bza |= bza ^= bza <<= bza >>= bza **= br!r"rrr�!test_simple_augmented_assignments�s










z>RoundtripLegalSyntaxTestCase.test_simple_augmented_assignmentscCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d �|�d!�|�d"�|�d#�|�d$�|�d%�|�d&�|�d'�|�d(�|�d)�|�d*�|�d+�|�d,�|�d-�|�d.�dS)/Nz
def f(): passzdef f(*args): passzdef f(*args, **kw): passzdef f(**kw): passzdef f(foo=bar): passzdef f(foo=bar, *args): passz!def f(foo=bar, *args, **kw): passzdef f(foo=bar, **kw): passzdef f(a, b): passzdef f(a, b, *args): passzdef f(a, b, *args, **kw): passzdef f(a, b, **kw): passzdef f(a, b, foo=bar): passz!def f(a, b, foo=bar, *args): passz'def f(a, b, foo=bar, *args, **kw): passz def f(a, b, foo=bar, **kw): passz@staticmethod
def f(): passz,@staticmethod
@funcattrs(x, y)
def f(): passz@funcattrs()
def f(): passzdef f(*, a): passzdef f(*, a = 5): passzdef f(*, a = 5, b): passzdef f(*, a, b = 5): passz def f(*, a, b = 5, **kwds): passzdef f(*args, a): passzdef f(*args, a = 5): passzdef f(*args, a = 5, b): passzdef f(*args, a, b = 5): passz$def f(*args, a, b = 5, **kwds): passzdef f(a, /): passzdef f(a, /,): passzdef f(a, b, /): passzdef f(a, b, /, c): passzdef f(a, b, /, c = 6): passzdef f(a, b, /, c, *, d): passz!def f(a, b, /, c = 1, *, d): passz!def f(a, b, /, c, *, d = 1): passz%def f(a, b=1, /, c=2, *, d = 3): passz'def f(a=0, b=1, /, c=2, *, d = 3): passzdef f(a: int): passzdef f(a: int = 5): passzdef f(*args: list): passzdef f(**kwds: dict): passzdef f(*, a: int): passzdef f(*, a: int = 5): passzdef f() -> int: passr!r"rrr�test_function_defs�s\












































z/RoundtripLegalSyntaxTestCase.test_function_defscCs6|�d�|�d�|�d�|�d�|�d�dS)Nzclass foo():passzclass foo(object):passz!@class_decorator
class foo():passz&@class_decorator(arg)
class foo():passz(@decorator1
@decorator2
class foo():passr!r"rrr�test_class_defss




z,RoundtripLegalSyntaxTestCase.test_class_defscCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�dS)Nzfrom sys.path import *zfrom sys.path import dirnamezfrom sys.path import (dirname)zfrom sys.path import (dirname,)z*from sys.path import dirname as my_dirnamez,from sys.path import (dirname as my_dirname)z-from sys.path import (dirname as my_dirname,)z&from sys.path import dirname, basenamez(from sys.path import (dirname, basename)z)from sys.path import (dirname, basename,)z4from sys.path import dirname as my_dirname, basenamez6from sys.path import (dirname as my_dirname, basename)z7from sys.path import (dirname as my_dirname, basename,)z5from sys.path import dirname, basename as my_basenamez7from sys.path import (dirname, basename as my_basename)z8from sys.path import (dirname, basename as my_basename,)zfrom .bogus import xr!r"rrr�test_import_from_statements:









������z7RoundtripLegalSyntaxTestCase.test_import_from_statementcCs6|�d�|�d�|�d�|�d�|�d�dS)Nz
import syszimport sys as systemzimport sys, mathzimport sys as system, mathzimport sys, math as my_mathr!r"rrr�test_basic_import_statement%s




z8RoundtripLegalSyntaxTestCase.test_basic_import_statementcCsT|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)	Nzfrom . import namezfrom .. import namezfrom ... import namezfrom .... import namezfrom .pkg import namezfrom ..pkg import namezfrom ...pkg import namezfrom ....pkg import namer!r"rrr�test_relative_imports,s






z2RoundtripLegalSyntaxTestCase.test_relative_importscCs|�d�dS)Nz"# -*- coding: iso-8859-1 -*-
pass
r!r"rrr�test_pep2638sz(RoundtripLegalSyntaxTestCase.test_pep263cCs|�d�dS)Nzassert alo < ahi and blo < bhi
r!r"rrr�test_assert<sz(RoundtripLegalSyntaxTestCase.test_assertcCs"|�d�|�d�|�d�dS)Nzwith open('x'): pass
zwith open('x') as f: pass
z*with open('x') as f, open('y') as g: pass
r!r"rrr�	test_with?s

z&RoundtripLegalSyntaxTestCase.test_withcCs@|�d�|�d�|�d�|�d�|�d�|�d�dS)Nztry: pass
except: pass
ztry: pass
finally: pass
z'try: pass
except A: pass
finally: pass
z4try: pass
except A: pass
except: pass
finally: pass
z"try: pass
except: pass
else: pass
z0try: pass
except: pass
else: pass
finally: pass
r!r"rrr�
test_try_stmtDs




z*RoundtripLegalSyntaxTestCase.test_try_stmtcCs|�d�|�d�dS)Nzif True:
  pass
else:
  pass
z/if True:
  pass
elif True:
  pass
else:
  pass
r!r"rrr�test_if_stmtNs
z)RoundtripLegalSyntaxTestCase.test_if_stmtcs@d}t�|�}�fdd��dddddd	d
ddd
ddddddg}|�t�|jddd���|�|�t�|����dd�|D��|�t�|jdd���dd�|D��|�t�|jdd���dd�|D��|�t�|jddd���dd�|D��|�t�tj|ddd���|�|�t�tj|ddd���dd�|D��dS)Nzdef f(x):
    return x + 1c3sP|d}|d}t|ttf�rF|dd�D]}�|�D]
}|Vq6q*n|VdS)Nr�)�
isinstance�tuple�list)�treeZ	node_type�nextZeltr��walkrrrCXsz8RoundtripLegalSyntaxTestCase.test_position.<locals>.walk)r<�defr<r)r<rr<�)��(r<�)r<rr<�)��)r<rF)��:r<rJ)rE�r<�	)rHrN����)r<�returnrPrE)r<rrPrL)��+rP�
)rP�1rP�)rErNrP�)rIrNrPrQ)rErNrPrQ)rrNrPrQT)�	line_info�col_infocSsg|]\}}}}||f�qSrr��.0r�n�l�crrr�
<listcomp>xs
z>RoundtripLegalSyntaxTestCase.test_position.<locals>.<listcomp>)rYcSsg|]\}}}}|||f�qSrrr[rrrr`zs
)rZcSsg|]\}}}}|||f�qSrrr[rrrr`|s
cSsg|]}t|��qSr�r?�r\rrrrr`~scSsg|]}t|��qSrrarbrrrr`�s)rrr
r?r�tolistZst2tupleZst2list)rr�stZexpectedrrBr�
test_positionRsZ
����������z*RoundtripLegalSyntaxTestCase.test_positioncCs,|�d�|�d�|�d�|�d�dS)Nz*a = yz
x, *b, = mz[*a, *b] = yzfor [*x, b] in x: passr!r"rrr�test_extended_unpacking�s


z4RoundtripLegalSyntaxTestCase.test_extended_unpackingcCs"|�d�|�d�|�d�dS)Nzraise
zraise e
zBtry:
    suite
except Exception as e:
    raise ValueError from e
r!r"rrr�test_raise_statement�s

z1RoundtripLegalSyntaxTestCase.test_raise_statementcCs|�d�|�d�dS)Nz[]z[*{2}, 3, *[4]]r)r"rrr�test_list_displays�s
z/RoundtripLegalSyntaxTestCase.test_list_displayscCs6|�d�|�d�|�d�|�d�|�d�dS)Nz{*{2}, 3, *[4]}z{2}z{2,}z{2, 3}z{2, 3,}r)r"rrr�test_set_displays�s




z.RoundtripLegalSyntaxTestCase.test_set_displayscCsJ|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)Nz{}z{a:b}z{a:b,}z
{a:b, c:d}z{a:b, c:d,}z{**{}}z{**{}, 3:4, **{5:6, 7:8}}r)r"rrr�test_dict_displays�s





z/RoundtripLegalSyntaxTestCase.test_dict_displayscCs6|�d�|�d�|�d�|�d�|�d�dS)Nz
f(*a, **b)zf(a, *b, *c, *d)zf(**a, **b)zf(2, *a, *b, **b, **c, **d)z0f(*b, *() or () and (), **{} and {}, **() or {})r)r"rrr�test_argument_unpacking�s




z4RoundtripLegalSyntaxTestCase.test_argument_unpackingcCs"|�d�|�d�|�d�dS)Nz{x for x in seq}z{f(x) for x in seq}z#{f(x) for x in seq if condition(x)}r)r"rrr�test_set_comprehensions�s

z4RoundtripLegalSyntaxTestCase.test_set_comprehensionscCs"|�d�|�d�|�d�dS)Nz{x:x for x in seq}z({x**2:x[3] for x in seq if condition(x)}z4{x:x for x in seq1 for y in seq2 if condition(x, y)}r)r"rrr�test_dict_comprehensions�s

z5RoundtripLegalSyntaxTestCase.test_dict_comprehensionscCs:|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)Nz(a := 1)z(a := a)z0if (match := pattern.search(data)) is None: passz-while match := pattern.search(f.read()): passz[y := f(x), y**2, y**3]z8filtered_data = [y for x in data if (y := f(x)) is None]z(y := f(x))zy0 = (y1 := f(x))zfoo(x=(y := f(x)))zdef foo(answer=(p := 42)): passz$def foo(answer: (p := 42) = 5): passzlambda: (x := 1)z(x := lambda: 1)z(x := lambda: (y := 1))z:lambda line: (m := re.match(pattern, line)) and m.group(1)zx = (y := 0)z(z:=(y:=(x:=0)))z(info := (name, phone, *rest))z(x:=1,2)z(total := total + tax)zlen(lines := f.readlines())zfoo(x := 3, cat='vector')zfoo(cat=(category := 'vector'))zAif any(len(longline := l) >= 100 for l in lines): print(longline)zFif env_base := os.environ.get('PYTHONUSERBASE', None): return env_basezNif self._is_special and (ans := self._check_nans(context=context)): return anszfoo(b := 2, a=1)zfoo((b := 2), a=1)zfoo(c=(b := 2), a=1)z{(x := C(i)).q: x for i in y}r!r"rrr�test_named_expressions�sF























��



z3RoundtripLegalSyntaxTestCase.test_named_expressionsN)%�__name__�
__module__�__qualname__rrrr r#r$r%r&r'r*r,r-r0r1r2r3r4r5r6r7r8r9r:r;rerfrgrhrirjrkrlrmrnrrrrrsD	
+'<
4	rc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IllegalSyntaxTestCasecCs8zt�|�Wntjk
r$YnX|�d|�dS)Nz"did not detect invalid tree for %r)rrrr	)rr@Zlabelrrr�check_bad_tree�s
z$IllegalSyntaxTestCase.check_bad_treecCs|�dd�dS)N)r<rP�z<junk>�rsr"rrr�	test_junk�szIllegalSyntaxTestCase.test_junkcCsDd}|�|d�d}|�|d�d}|�|d�d}|�|d�dS)	N)�)�
)�)�)�)r<�rErNr|�rrNz too small items in terminal node)rw)rx)ry)rz)r{)r<spassr|r|r}z'non-string second item in terminal node)rw)rx)ry)rz)r{)r<�pass�0rr|r|r}z'non-integer third item in terminal node)rw)rx)ry)rz)r{)r<r~rrr|r|r}ztoo many items in terminal noderu�rr@rrr�test_illegal_terminal�s�
�
�
�
z+IllegalSyntaxTestCase.test_illegal_terminalcCsd}|�|d�dS)N)rw��)�)i)r<rD)r<r)i)rFrG)rJrK)rLrM)�#r|)rHrN)r�)�	)�
)�)i)r<rR�i9)�$)�%)�&)�')�))�*)�+)�,)�-)�.)�/)�0)i1)rPrV)r�)r�)r�)r�)i)r<�yieldr�r|)rIrNr|r}�def f():
  return 1
  yield 1rur�rrr�test_illegal_yield_1 s�3z*IllegalSyntaxTestCase.test_illegal_yield_1cCsd}|�|d�dS)N)rw)r�)r�)r�)i�r<�from)i)r<Z
__future__�r<�import)i)r<Z
generatorsr|r�r�rur�rrr�test_illegal_yield_2Ws�<z*IllegalSyntaxTestCase.test_illegal_yield_2cCsd}|�|d�dS)N)i)i7)�")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}za,,crur�rrr�test_a_comma_comma_c�s�z*IllegalSyntaxTestCase.test_a_comma_comma_ccCsd}|�|d�dS)N)rw)r�)r�)r�)i)�8)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�r�)�)�%z$=)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r�)r<�br|r}za $= brur�rrr�test_illegal_operator�s�z+IllegalSyntaxTestCase.test_illegal_operatorcCsd}|�|d�dS)N)rw)r�)r�)r�)�)r<Zfoor|r|r}zmalformed global astrur�rrr�test_malformed_global�sz+IllegalSyntaxTestCase.test_malformed_globalcCsd}|�|d�dS)N)rw)r�)rx)ry)r�)ir�r�)i)r�)r<Zfredr|r|r}zfrom import fredrur�rrr�test_missing_import_source�s�
z0IllegalSyntaxTestCase.test_missing_import_sourcec	CsHd}|�|d�d}|�|d�d}|�t��t�|�W5QRXdS)N)�U�rwr}zmissed encoding)r�r�s
iso-8859-1znon-string encoding)r�r�u�)rsr.�UnicodeEncodeErrorrrr�rrr�test_illegal_encoding�s���z+IllegalSyntaxTestCase.test_illegal_encodingcCs4d}|�|d�d}|�|d�d}|�|d�dS)N)rw)rx)i����rNznegative node id)rw)rx)�crNzinvalid token id)rw)rx)i'r}zinvalid symbol idrur�rrr�test_invalid_node_id�sz*IllegalSyntaxTestCase.test_invalid_node_idc
CsXzt�d�WnDtjk
rR}z$|�dt|��|�dt|��W5d}~XYnXdS)N)rw)rxr�Z
compound_stmtZ
file_input)rrr�assertInr)rrrrr�test_ParserError_messages
z.IllegalSyntaxTestCase.test_ParserError_messageN)rorprqrsrvr�r�r�r�r�r�r�r�r�r�rrrrrr�s.7@!rrc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�CompileTestCasecCs(t�d�}t�|�}|�t|�d�dS)N�2 + 3rH�rr�	compilestr
�eval)rrdrrrr�test_compile_exprs

z!CompileTestCase.test_compile_exprcCs6t�d�}t�|�}i}t||�|�|dd�dS)N�x = 2; y = x + 3�yrH)rrr�rr
)rrdrZglobsrrr�test_compile_suites



z"CompileTestCase.test_compile_suitecCst�d�}|�ttj|�dS)Nz	1 = 3 + 4�rrr.r/r��rrdrrr�test_compile_errors
z"CompileTestCase.test_compile_errorcCs8t�d�}|�ttj|�t�d�}|�ttj|�dS)Nza = "\U12345678"z	a = "\u1"r�r�rrr�test_compile_badunicode#s

z'CompileTestCase.test_compile_badunicodecCsBt�d�}t�|�}|�t|�d�t�|�}|�t|�d�dS)Nz-3���r�)rrd�code1�code2rrr�test_issue_9011)s



zCompileTestCase.test_issue_9011c
Cst�d�}t�|�}|�|jd�|��}|�|jd�dD]6}t�||�}|�|jd�|�|�}|�|jd�q<td�td�fD]b}|�t	��t�||�}W5QRX|�|jd�|�t	��|�|�}W5QRX|�|jd�q�|�
ttj|td��|�
t|jtd��dS)Nza + 5z
<syntax-tree>)�file.py�file.pyr�r�)
rrr�r
�co_filenamer�	bytearray�
memoryviewZassertWarns�DeprecationWarningr.�	TypeErrorr?)rrdr�filenamerrr�test_compile_filename3s&


z%CompileTestCase.test_compile_filenameN)	rorprqr�r�r�r�r�r�rrrrr�s
r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ParserStackLimitTestCasezitry to push the parser to/over its limits.
    see http://bugs.python.org/issue1881 for a discussion
    cCsd|d|S)N�[�]r)r�levelrrr�_nested_expressionMsz+ParserStackLimitTestCase._nested_expressioncCs |�d�}t�|�}|��dS)Nr�)r�rrr)r�erdrrr�test_deeply_nested_listPs

z0ParserStackLimitTestCase.test_deeply_nested_listcCs6|�d�}td|�\}}}|�d|�|�d|�dS)N�dz-css_push: parser stack overflowsMemoryError)r�rr�)rr��rc�out�errrrr�test_trigger_memory_errorWs
z2ParserStackLimitTestCase.test_trigger_memory_errorN)rorprq�__doc__r�r�r�rrrrr�Isr�c@s4eZdZdZdd�Zdd�ZejZejdd��Z	dS)	�STObjectTestCasez(Test operations on ST objects themselvesc
Cst�d�}t�d�}t�d�}t�d�}t�d�}t�d�}|�||kd�|�||kd�|�||kd�|�||�|�||�|�||�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||kd�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�|�||k||k�t|||�}t|||�}t|||g�d}	|�||	k�|�||k�|�|	|k�|�||	k�|�||k�|�|	|k�|�||k�|�|	|	k�|�||k�|�|dkd�|�d|kd�|�t	t
j|d�|�t	t
jd|�|�t	t
j
|d	�|�t	t
jd
|�dS)Nr�r�r(TFr<g��hҘ@zspanish armadaiswaterloo)rrrr
�min�max�sortedZ
assertTruer.r��operator�ge�le�lt�gt)
rrrZst3Zst1_copyZst2_copyZst3_copyZbottom�topZmidrrr�test_comparisonsbsf





z!STObjectTestCase.test_comparisonscCs�t�d�t�d�t�d�g}|D]z}t�|�}|�|��|���t�|�}|�|��|���ttj	d�D]*}t�
t�||��}|�|��|���qnq dS)Nr�r�r(r<)rrr�copyr
r�deepcopy�range�pickle�HIGHEST_PROTOCOL�loads�dumps)r�stsrdZst_copy�protorrr�test_copy_pickle�s�

z!STObjectTestCase.test_copy_picklecs�dd��t�d��t�d�����fdd������fdd�}|t�d	��|t�d
��|t�d��|t�d��|t�d
��|t�d��dS)NcSs0|dkr|S|dkr |dd@Sd|d��>S)Nr<�rt���)�
bit_length)r]rrr�
XXXROUNDUP�s
z0STObjectTestCase.test_sizeof.<locals>.XXXROUNDUPZPiiiZ	hP3iP0h2ics�|dkrdSd}t|�dko(t|dt�}|rB|t|d�d7}|rR|dd�n
|dd�}|r�|�t|���7}|D]}|�|�7}qz|S)Nrr<rQ)�lenr=r)Znode�res�hasstrZchildrenZchild)r��nodesize�sizeofchildrenrrr��sz4STObjectTestCase.test_sizeof.<locals>.sizeofchildrencs ��|���|����dSr)�check_sizeofr)rd)�basesizer�rr�rr�check_st_sizeof�s
�z5STObjectTestCase.test_sizeof.<locals>.check_st_sizeofr�z	2 + 3 + 4z	x = 2 + 3rNz# -*- coding: utf-8 -*-a�[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,])rZcalcobjsize�struct�calcsizerrr)rr�r)r�r�r�rr�r�test_sizeof�s

zSTObjectTestCase.test_sizeofN)
rorprqr�r�r�rr�Zcpython_onlyr�rrrrr�_s=r�c@seZdZdd�ZdS)�OtherParserCasec	Cs&|�t��t�dd�W5QRXdS)Nr+r�)r.r�rrr"rrr�test_two_args_to_expr�sz%OtherParserCase.test_two_args_to_exprN)rorprqrrrrrr�sr�__main__)r�rr�Zunittestr�r��testrZtest.support.script_helperrZTestCaserrrr�r�r�rro�mainrrrr�<module>s(W-:x

F1le Man4ger