%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_code.pyc


Nac@sdZddlZddlZddlmZmZmZdZdZdej	fdYZ
dZd	ej	fd
YZdej	fdYZ
dd
ZedkrendS(sThis 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')

iN(trun_doctesttrun_unittesttcpython_onlyccsDx=|D]5}t|}|jdr7d|jVq|VqWdS(s.Yield a doctest-safe sequence of object reprs.s<code objects<code object %s>N(treprt
startswithtco_name(tttelttr((s*/usr/local/lib/python2.7/test/test_code.pytconstsXs

cCsaxBddddddddgD]"}d	|t|d
|fGHqWdGtt|jGHdS(
s1Print out a text representation of a code object.tnametargcounttnamestvarnamestcellvarstfreevarstnlocalstflagss%s: %stco_sconsts:N(tgetattrttupleR	t	co_consts(tcotattr((s*/usr/local/lib/python2.7/test/test_code.pytdumpas tCodeTestcBseZedZRS(cCs^ddl}|jddd}|j|jd|j|jd|j|jddS(Nitfilenametfuncnamei(t	_testcapit
code_newemptytassertEqualtco_filenameRtco_firstlineno(tselfRR((s*/usr/local/lib/python2.7/test/test_code.pyt
test_newemptyks
(t__name__t
__module__RR"(((s*/usr/local/lib/python2.7/test/test_code.pyRiscCs|td|ddd!kS(Nt_ii(tintern(ts((s*/usr/local/lib/python2.7/test/test_code.pyt
isinternedtstCodeConstsTestcBs_eZdZdZdZedZedZedZedZ	RS(cCsBx|D]}||kr|SqW|j|||jddS(NsShould never be reached(tassertIntfail(R!R	tvaluetv((s*/usr/local/lib/python2.7/test/test_code.pyt
find_constys

cCs't|s#|jd|fndS(NsString %r is not interned(R(R+(R!R'((s*/usr/local/lib/python2.7/test/test_code.pytassertIsInternedscCs't|r#|jd|fndS(NsString %r is interned(R(R+(R!R'((s*/usr/local/lib/python2.7/test/test_code.pytassertIsNotInternedscCs8tddd}|j|jd}|j|dS(Nsres = "str_value"t?texect	str_value(tcompileR.RR/(R!RR-((s*/usr/local/lib/python2.7/test/test_code.pyttest_interned_stringscCs<tddd}|j|jd}|j|ddS(Nsres = ("str_value",)R1R2R3i(R3(R4R.RR/(R!RR-((s*/usr/local/lib/python2.7/test/test_code.pyttest_interned_string_in_tuplescCs dd}|j|dS(NR3cSs|S(N((ta((s*/usr/local/lib/python2.7/test/test_code.pytfs(R/(R!R8((s*/usr/local/lib/python2.7/test/test_code.pyttest_interned_string_defaultscCs8tddd}|j|jd}|j|dS(Nsres = "str\0value!"R1R2s
strvalue!(R4R.RR0(R!RR-((s*/usr/local/lib/python2.7/test/test_code.pyttest_interned_string_with_nulls(
R#R$R.R/R0RR5R6R9R:(((s*/usr/local/lib/python2.7/test/test_code.pyR)ws			tCodeWeakRefTestcBseZdZRS(csi}de|U|d}~e_fd}ej|j|}je|~je|jjdS(Ns
def f(): passR8cs
t_dS(N(tTruetcalled(tcode(R!(s*/usr/local/lib/python2.7/test/test_code.pytcallbacks(	tglobalstFalseR=tweakreftreft__code__t
assertTruetbooltassertFalse(R!t	namespaceR8R?tcoderef((R!s*/usr/local/lib/python2.7/test/test_code.pyt
test_basics

	(R#R$RJ(((s*/usr/local/lib/python2.7/test/test_code.pyR;scCs1ddlm}t||ttttdS(Ni(t	test_code(ttestRKRRRR)R;(tverboseRK((s*/usr/local/lib/python2.7/test/test_code.pyt	test_mains
t__main__(t__doc__tunittestRBttest.test_supportRRRR	RtTestCaseRR(R)R;tNoneRNR#(((s*/usr/local/lib/python2.7/test/test_code.pyt<module>Qs				*

Zerion Mini Shell 1.0