Current File : //opt/imh-python/lib/python2.7/test/test_code.pyo
�
��Wc@s�dZddlZddlZddlmZmZmZd�Zd�Zdej	fd��YZ
dej	fd	��YZdd
�Z
edkr�e
�ndS(s�This module includes tests of the code object representation.

>>> def f(x):
...     def g(y):
...         return x + y
...     return g
...

>>> dump(f.func_code)
name: f
argcount: 1
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
freevars: ()
nlocals: 2
flags: 3
consts: ('None', '<code object g>')

>>> dump(f(4).func_code)
name: g
argcount: 1
names: ()
varnames: ('y',)
cellvars: ()
freevars: ('x',)
nlocals: 1
flags: 19
consts: ('None',)

>>> def h(x, y):
...     a = x + y
...     b = x - y
...     c = a * b
...     return c
...
>>> dump(h.func_code)
name: h
argcount: 2
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
freevars: ()
nlocals: 5
flags: 67
consts: ('None',)

>>> def attrs(obj):
...     print obj.attr1
...     print obj.attr2
...     print obj.attr3

>>> dump(attrs.func_code)
name: attrs
argcount: 1
names: ('attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
nlocals: 1
flags: 67
consts: ('None',)

>>> def optimize_away():
...     'doc string'
...     'not a docstring'
...     53
...     53L

>>> dump(optimize_away.func_code)
name: optimize_away
argcount: 0
names: ()
varnames: ()
cellvars: ()
freevars: ()
nlocals: 0
flags: 67
consts: ("'doc string'", 'None')

i����N(trun_doctesttrun_unittesttcpython_onlyccsDx=|D]5}t|�}|jd�r7d|jVq|VqWdS(s.Yield a doctest-safe sequence of object reprs.s<code objects<code object %s>N(treprt
startswithtco_name(tttelttr((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pytconstsXs

cCsaxBddddddddgD]"}d	|t|d
|�fGHqWdGtt|j��GHdS(
s1Print out a text representation of a code object.tnametargcounttnamestvarnamestcellvarstfreevarstnlocalstflagss%s: %stco_sconsts:N(tgetattrttupleR	t	co_consts(tcotattr((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pytdumpas tCodeTestcBseZed��ZRS(cCs^ddl}|jddd�}|j|jd�|j|jd�|j|jd�dS(Ni����tfilenametfuncnamei(t	_testcapit
code_newemptytassertEqualtco_filenameRtco_firstlineno(tselfRR((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyt
test_newemptyks
(t__name__t
__module__RR"(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyRistCodeWeakRefTestcBseZd�ZRS(cs�i}de�|U|d}~e�_�fd�}ej|j|�}�je|���~�je|����j�j�dS(Ns
def f(): passtfcs
t�_dS(N(tTruetcalled(tcode(R!(sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pytcallbacks(	tglobalstFalseR(tweakreftreft__code__t
assertTruetbooltassertFalse(R!t	namespaceR&R*tcoderef((R!sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyt
test_basicvs

	(R#R$R5(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyR%tscCs.ddlm}t||�ttt�dS(Ni����(t	test_code(ttestR6RRRR%(tverboseR6((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyt	test_main�s
t__main__(t__doc__tunittestR-ttest.test_supportRRRR	RtTestCaseRR%tNoneR9R#(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_code.pyt<module>Qs