Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_code.cpython-35.opt-2.pyc



���]��@s�ddlZddlZddlZddlmZmZmZdd�Zdd�ZGdd�dej	�Z
d	d
�ZGdd�dej	�ZGd
d�dej	�Z
ddd�Zedkr�e�dS)�N)�run_doctest�run_unittest�cpython_onlyccsDx=|D]5}t|�}|jd�r7d|jVq|VqWdS)Nz<code objectz<code object %s>)�repr�
startswith�co_name)�tZelt�r�r
�./opt/alt/python35/lib64/python3.5/test_code.py�constsos

rc	CsmxJddddddddd	g	D]'}td
|t|d|�f�q"Wtdtt|j���dS)
N�nameZargcountZkwonlyargcount�namesZvarnamesZcellvarsZfreevarsZnlocals�flagsz%s: %sZco_zconsts:)�print�getattr�tupler�	co_consts)�co�attrr
r
r�dumpxs%rc@s"eZdZedd��ZdS)�CodeTestcCs^ddl}|jddd�}|j|jd�|j|jd�|j|jd�dS)Nr�filename�funcname�)�	_testcapiZ
code_newemptyZassertEqual�co_filenamer�co_firstlineno)�selfrrr
r
r�
test_newempty�s
zCodeTest.test_newemptyN)�__name__�
__module__�__qualname__rrr
r
r
rr�srcCs%|tjd|ddd��kS)N�_����)�sys�intern)�sr
r
r�
isinterned�sr)c@s�eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��ZdS)�CodeConstsTestcCsBx|D]}||kr|SqW|j||�|jd�dS)NzShould never be reached)ZassertIn�fail)rr�value�vr
r
r�
find_const�s

zCodeConstsTest.find_constcCs$t|�s |jd|f�dS)NzString %r is not interned)r)r+)rr(r
r
r�assertIsInterned�szCodeConstsTest.assertIsInternedcCs$t|�r |jd|f�dS)NzString %r is interned)r)r+)rr(r
r
r�assertIsNotInterned�sz"CodeConstsTest.assertIsNotInternedcCs8tddd�}|j|jd�}|j|�dS)Nzres = "str_value"�?�exec�	str_value)�compiler.rr/)rrr-r
r
r�test_interned_string�sz#CodeConstsTest.test_interned_stringcCs<tddd�}|j|jd�}|j|d�dS)Nzres = ("str_value",)r1r2r3r)r3)r4r.rr/)rrr-r
r
r�test_interned_string_in_tuple�sz,CodeConstsTest.test_interned_string_in_tuplecCsHtddd�}|j|jtd��}|jt|�d�dS)Nzres = a in {"str_value"}r1r2r3r)r3)r4r.r�	frozensetr/r)rrr-r
r
r�!test_interned_string_in_frozenset�sz0CodeConstsTest.test_interned_string_in_frozensetcCs#ddd�}|j|��dS)Nr3cSs|S)Nr
)�ar
r
r�f�sz6CodeConstsTest.test_interned_string_default.<locals>.f)r/)rr:r
r
r�test_interned_string_default�sz+CodeConstsTest.test_interned_string_defaultcCs8tddd�}|j|jd�}|j|�dS)Nzres = "str\0value!"r1r2z
strvalue!)r4r.rr0)rrr-r
r
r�test_interned_string_with_null�sz-CodeConstsTest.test_interned_string_with_nullN)r r!r"r.r/r0rr5r6r8r;r<r
r
r
rr*�sr*c@seZdZdd�ZdS)�CodeWeakRefTestcs�i}tdt�|�|d}~d�_�fdd�}tj|j|�}�jt|���~�jt|����j�j�dS)Nz
def f(): passr:Fcs
d�_dS)NT)�called)�code)rr
r�callback�sz,CodeWeakRefTest.test_basic.<locals>.callback)	r2�globalsr>�weakref�ref�__code__Z
assertTrue�boolZassertFalse)r�	namespacer:r@Zcoderefr
)rr�
test_basic�s
	zCodeWeakRefTest.test_basicN)r r!r"rGr
r
r
rr=�sr=cCs1ddlm}t||�tttt�dS)Nr)�	test_code)ZtestrHrrrr*r=)�verboserHr
r
r�	test_main�s
rJ�__main__)r&ZunittestrBZtest.supportrrrrrZTestCaserr)r*r=rJr r
r
r
r�<module>is	0