o !b@sddlZddlZddlZddlZddlmZddlZddlmZddl m Z ddl m Z m Z mZmZmZddlmZmZmZGdddejZGd d d ejZd d Zed kr`ejd ddSdS)N)mkstemp)Markup)Context) ExpressionSuite UndefinedUndefinedError UNDEFINED)BytesIO IS_PYTHON2 wrapped_bytesc@sneZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d"Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDdEZ$dFdGZ%dHdIZ&dJdKZ'dLdMZ(dNdOZ)dPdQZ*dRdSZ+dTdUZ,dVdWZ-dXdYZ.dZd[Z/d\d]Z0d^d_Z1d`daZ2dbdcZ3dddeZ4e5j6dfkrdgdhZ7didjZ8dkdlZ9dmdnZ:dodpZ;dqdrZdwdxZ?dydzZ@d{d|ZAd}d~ZBddZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNdS)ExpressionTestCasecCs,td}||td||tddSNzx,yzy, x)r assertEqualassertNotEqualselfexprrz+1z+xxr;r'rrrtest_unaryop_posnz#ExpressionTestCase.test_unaryop_poscC4|dtdi|dtdddidS)Nz-1z-xrBr>r;r'rrrtest_unaryop_negrrDz#ExpressionTestCase.test_unaryop_negcCrE)NFznot Trueznot xrBTr;r'rrrtest_unaryop_notvrDz#ExpressionTestCase.test_unaryop_notcCrE)Nz~1z~xrBr>r;r'rrrtest_unaryop_invzrDz#ExpressionTestCase.test_unaryop_invcC6|dtdi|dtdddddS)Nr?z2 + 1zx + yrr>rByr;r'rrrtest_binop_add~ z!ExpressionTestCase.test_binop_addcCs6|dtdi|dtdddddS)Nr>2 - 1x - yrLr;r'rrrtest_binop_subrOz!ExpressionTestCase.test_binop_subcC6|dtdi|dtdddddS)Nr>rPrQrrLr;r'rrrrRrOcC6|dtdi|dtdddddS)Nz2 * 2zx * yrrLr;r'rrrtest_binop_mulrOz!ExpressionTestCase.test_binop_mulcCrT)NrUz2 ** 2zx ** yrrLr;r'rrrtest_binop_powrOz!ExpressionTestCase.test_binop_powcCrS)Nrz4 / 2zx / yrUrLr;r'rrrtest_binop_divrOz!ExpressionTestCase.test_binop_divcCrK)Nr>z3 // 2zx // yr?rrLr;r'rrrtest_binop_floordivrOz&ExpressionTestCase.test_binop_floordivcCrK)Nr>z3 % 2zx % yr?rrLr;r'rrrtest_binop_modrOz!ExpressionTestCase.test_binop_modcCrS)Nrz1 & 0zx & yr>rLr;r'rrrtest_binop_andrOz!ExpressionTestCase.test_binop_andcC6|dtdi|dtdddddS)Nr>z1 | 0zx | yrrLr;r'rrr test_binop_orrOz ExpressionTestCase.test_binop_orcCr\)Nr>z1 ^ 0zx ^ yrrLr;r'rrrtest_binop_xorrOz!ExpressionTestCase.test_binop_xorcCrK)NTz1 in (1, 2, 3)zx in yr>r=rLr;r'rrrtest_binop_containsz&ExpressionTestCase.test_binop_containscCrK)NTz4 not in (1, 2, 3)z x not in yrUr=rLr;r'rrrtest_binop_not_containsr`z*ExpressionTestCase.test_binop_not_containscCsh|dtdi|dtdddd|dtdi|dtdddddS) NTz1 is 1zx is yr>rLFz1 is 2rr;r'rrr test_binop_iss z ExpressionTestCase.test_binop_iscCsh|dtdi|dtdddd|dtdi|dtdddddS) NTz 1 is not 2z x is not yr>rrLFz 1 is not 1r;r'rrrtest_binop_is_nots z$ExpressionTestCase.test_binop_is_notcCrS)NFzTrue and Falsezx and yTrLr;r'rrrtest_boolop_andr`z"ExpressionTestCase.test_boolop_andcCr\)NTz True or Falsezx or yFrLr;r'rrrtest_boolop_orr`z!ExpressionTestCase.test_boolop_orcCrT)NTz1 == 1zx == yr>rLr;r'rrrtest_compare_eqrOz"ExpressionTestCase.test_compare_eqcCsv|dtdi|dtddddtjdkr9|dtdi|dtdddddSdS) NFz1 != 1zx != yr>rL3z1 <> 1zx <> y)rrrsysversionr'rrrtest_compare_nes   z"ExpressionTestCase.test_compare_necCrK)NTrzx < yr>rrLr;r'rrrtest_compare_ltrOz"ExpressionTestCase.test_compare_ltcCrT)NTz1 <= 1zx <= yr>rLr;r'rrrtest_compare_lerOz"ExpressionTestCase.test_compare_lecCrK)NTz2 > 1zx > yrr>rLr;r'rrrtest_compare_gtrOz"ExpressionTestCase.test_compare_gtcCrT)NTz1 >= 1zx >= yr>rLr;r'rrrtest_compare_gerOz"ExpressionTestCase.test_compare_gecCrK)NTz 1 != 3 == 3z x != y == yr>r?rLr;r'rrrtest_compare_multir`z%ExpressionTestCase.test_compare_multicCsf|dtddddiddi}|dtd|ddtdii}|dtd |dS) Nr0zfoo()r%cSdS)Nr0rrrrrz7ExpressionTestCase.test_call_function..r$BARz foo.upper()z len(foo.bar))rrrrangerdatarrrtest_call_functions z%ExpressionTestCase.test_call_functioncCs$|dtddddddS)Nr0z foo(x=bar)cS|SNrrBrrrrqrrz7ExpressionTestCase.test_call_keywords..r%r$r;r'rrrtest_call_keywordssz%ExpressionTestCase.test_call_keywordscCs&|dtddddgddS)Nr0z foo(*bar)cSrxryrrzrrrrqrrz8ExpressionTestCase.test_call_star_args..r{r;r'rrrtest_call_star_argssz&ExpressionTestCase.test_call_star_argscCs0dd}td}|d||ddiddS)NcSrxryrrzrrrr%z4ExpressionTestCase.test_call_dstar_args..fooz foo(**bar)r0rBr{rrr)rr%rrrrtest_call_dstar_argss z'ExpressionTestCase.test_call_dstar_argscCs2dtdi}td}|ddgt||dS)Nitemszfilter(lambda x: x > 2, items)r?rU)rtrrlistrrrvrrrr test_lambdas zExpressionTestCase.test_lambdacCs8tsdSdddgi}td}|dgt||dS)Nrr>r)rr>z#filter(lambda (x, y): x > y, items))r rrrrrrrrtest_lambda_tuple_args  z(ExpressionTestCase.test_lambda_tuple_argc Ctd}|ddg|dtditd}|gd|dtditd}|gd |tdd d td }|gd |dtd tdgitd}|gd|ddgddgddS)Nz[n for n in numbers if n < 2]rr>numbersrz+[(i, n + 1) for i, n in enumerate(numbers)])rr>r)rr?)r?rU)rUrz[offset + n for n in numbers]rr?rUrrroffsetz&[n for group in groups for n in group]rr>rr>rgroupsr?z[(a, b) for a in x for b in y])x0y0)ry1)x1r)rrrrrrrLrrrrtrrrrtest_list_comprehension$    z*ExpressionTestCase.test_list_comprehensioncC8ddddddg}td}|dg|d|idS)Nar>namer:brz&[i.name for i in items if i.value > 1]rrrrrrrr$test_list_comprehension_with_getattr"z7ExpressionTestCase.test_list_comprehension_with_getattrcCr)Nrr>rrrz,[i['name'] for i in items if i['value'] > 1]rrrrrr$test_list_comprehension_with_getitem'rz7ExpressionTestCase.test_list_comprehension_with_getitemc Cr)Nz!list(n for n in numbers if n < 2)rr>rrz/list((i, n + 1) for i, n in enumerate(numbers))rz!list(offset + n for n in numbers)rrrz*list(n for group in groups for n in group)rrr?z"list((a, b) for a in x for b in y)rrrrrrLrrrrrtest_generator_expression,rz,ExpressionTestCase.test_generator_expressioncCr)Nrr>rrrz*list(i.name for i in items if i.value > 1)rrrrrr&test_generator_expression_with_getattr@rz9ExpressionTestCase.test_generator_expression_with_getattrcCr)Nrr>rrrz0list(i['name'] for i in items if i['value'] > 1)rrrrrr&test_generator_expression_with_getitemErz9ExpressionTestCase.test_generator_expression_with_getitem)rrcCs8td}|d|ddi|d|ddidS)Nz'T' if foo else 'F'Tr%TFFrrrrrtest_conditional_expressionKsz.ExpressionTestCase.test_conditional_expressionc Cs.td}|ddg|dttdidS)Nz numbers[0:2]rr>rrrrrrrtrrrr test_slicePs&zExpressionTestCase.test_slicecCs6td}|ttdddd}|ddg|dS)Nznumbers[start:end]rrrrstartendr>rrrrtrrrresrrrtest_slice_with_varsTsz'ExpressionTestCase.test_slice_with_varscC2td}|dttdi}|gd|dS)Nz numbers[:]rrrr>rr?rUrrrrrtest_slice_copyYz"ExpressionTestCase.test_slice_copycCs4td}|ttddd}|gd|dS)Nznumbers[::stride]rrrstriderrrUrrrrrtest_slice_stride^sz$ExpressionTestCase.test_slice_stridec Cs,td}|dg|dttdidS)Nz numbers[-1:]rUrrrrrrrtest_slice_negative_startcs$z,ExpressionTestCase.test_slice_negative_startcCr)Nz numbers[:-1]rrrr>rr?rrrrrtest_slice_negative_endgrz*ExpressionTestCase.test_slice_negative_endcCs.td}|dttdi}||ddS)Nz numbers[1]rrr>rrrrrtest_slice_constantlsz&ExpressionTestCase.test_slice_constantcCs8dd}td}|ttd|d}||ddS)NcSrpNrrrrrrfrr~z-ExpressionTestCase.test_slice_call..fz numbers[f()]rrrrr)rrrrrrrtest_slice_callqsz"ExpressionTestCase.test_slice_callcCs0td}|ttddd}||ddS)Nz numbers[v]rrrvrrrrrtest_slice_namexsz"ExpressionTestCase.test_slice_namecCs@Gddd}td}|ttd|d}||ddS)Nc@eZdZddZdS)z.ValueHoldercS d|_dSNr?r:r'rrr__init__ zEExpressionTestCase.test_slice_attribute..ValueHolder.__init__N__name__ __module__ __qualname__rrrrr ValueHolder~ rznumbers[obj.value]rrobjr?r)rrrrrrrtest_slice_attribute}sz'ExpressionTestCase.test_slice_attributecCsHtddddd}|i}t|tsJ|d|j|jtus"JdS)Nnothing index.html2lenientfilenamelinenolookup)rr isinstancerr_name_ownerr )rrretvalrrrtest_access_undefineds z(ExpressionTestCase.test_access_undefinedcCbGdddt}|}tddddd}|d|i}t|ts!J|d |j|j|us/JdS) Nc@r)z.SomethingcSrpNz rr'rrr__repr__r~zEExpressionTestCase.test_getattr_undefined..Something.__repr__Nrrrrrrrr Somethingrr something.nilrrrr somethingnilobjectrrrrrrrrrrrrrrrtest_getattr_undefinedz)ExpressionTestCase.test_getattr_undefinedcCsHGdddt}|ttdjd|i|ttdjd|idS)Nc@s,eZdZddZeeZddZeeZdS)z.SomethingcStryNotImplementedErrorr'rrrprop_ar~zCExpressionTestCase.test_getattr_exception..Something.prop_acSrry)AttributeErrorr'rrrprop_br~zCExpressionTestCase.test_getattr_exception..Something.prop_bN)rrrrpropertyrrrrrrs  rzs.prop_aszs.prop_b)r assertRaisesrrrrrrrrrtest_getattr_exceptionsz)ExpressionTestCase.test_getattr_exceptioncCr) Nc@r)zCExpressionTestCase.test_getitem_undefined_string..SomethingcSrprrr'rrrrr~zLExpressionTestCase.test_getitem_undefined_string..Something.__repr__Nrrrrrrrrsomething["nil"]rrrrrrrrrrrtest_getitem_undefined_stringrz0ExpressionTestCase.test_getitem_undefined_stringcCs.Gdddt}|ttdjd|idS)Nc@r)z.SomethingcSrryr)rr9rrr __getitem__r~zHExpressionTestCase.test_getitem_exception..Something.__getitem__N)rrrrrrrrrrrzs["foo"]r)rrrrrrrrrtest_getitem_exceptionsz)ExpressionTestCase.test_getitem_exceptionc Cstddddd}z |i|dWdStyi}zHt\}}}|j}g}|jr7|j}|||js,|dt ||d|d j j j |d|d j j j |d|d jWYd}~dSd}~ww) NrrrstrictrExpected UndefinedErrorz"nothing" not definedz)rrfailrrhexc_infotb_nextappendrstrtb_framef_codeco_name co_filename tb_lineno)rreexc_type exc_value exc_tracebackframeframesrrrtest_error_access_undefineds0     z.ExpressionTestCase.test_error_access_undefinedc CGdddt}tddddd}z|d|i|d WdStym}zA|d t|t\}}}d }|j }|j rO|j }|j j } | j |krLn|j s?|d |d| j |d|jWYd}~dSd}~ww) Nc@r)zBExpressionTestCase.test_error_getattr_undefined..SomethingcSrprrr'rrrrr~zKExpressionTestCase.test_error_getattr_undefined..Something.__repr__Nrrrrrrrrrrrrrrr% has no member named "nil"z'never found the frame I was looking forrrrrrrrrhrrrrrrr rrrr r r r  search_stringr r rrrtest_error_getattr_undefined.  z/ExpressionTestCase.test_error_getattr_undefinedc Cr) Nc@r)zIExpressionTestCase.test_error_getitem_undefined_string..SomethingcSrprrr'rrrrr~zRExpressionTestCase.test_error_getitem_undefined_string..Something.__repr__Nrrrrrrrrrrrrrrrrzrrrrrr#test_error_getitem_undefined_stringrz6ExpressionTestCase.test_error_getitem_undefined_stringcC(tddid}|dtd|dS)Nsomething)dictz dict['some']rrrrrurrr!test_getitem_with_constant_stringz4ExpressionTestCase.test_getitem_with_constant_stringcCstddddddd}|dtd||dtd ||dtd ||dtd ||dtd |dS) Nr$bazquoxquoooxfoobar)Tg@Nr0sfoovaluesz values[True]z values[2.5]z values[42]zvalues[b"foo"]z values[None]rrurrrtest_getitem_with_simple_indexs z1ExpressionTestCase.test_getitem_with_simple_indexcCs>tgdd}|dtd||dtd|dS)Nr=)rr>zitems[0]r?z items[-1]rrurrrtest_array_indicessz%ExpressionTestCase.test_array_indicescCsbGdddt}|dd}|dtd||dtd||dtd|dS) Nc@seZdZdZdS)zCExpressionTestCase.test_item_access_for_attributes..MyClassBarN)rrrmyattrrrrrMyClasssr*r))miner9r(z mine.myattrzmine["myattr"]z mine[key])rrrr)rr*rvrrrtest_item_access_for_attributess  z2ExpressionTestCase.test_item_access_for_attributescCr)Nr%r$r$zvalues[str("foo")]rrurrrtest_function_in_item_accessrz/ExpressionTestCase.test_function_in_item_accessN)Orrrrrr#r(r)r-r/r8r<r@rArCrGrHrJrNrRrVrWrXrYrZr[r]r^r_rarbrcrdrerfrjrkrlrmrnrorwr|r}rrrrrrrrrrh version_inforrrrrrrrrrrrrrrrrrrrr&r'r,r-rrrrr s        r c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e s6ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdNZ*dOdPZ+dQdRZ,e-j.dSkrdTdUZ/dVdWZ0dXdYZ1dZd[Z2d\d]Z3d^d_Z4d`daZ5dbdcZ6dddeZ7dfdgZ8dhdiZ9djS)k SuiteTestCasecCsbtd}t}t||d|dt|}i}|||d|d|j|jks/JdS)Nfoo = 42rrr0r%) rr rrrrexecuterr )rsuiter!r"rvrrrr##s   zSuiteTestCase.test_picklecCs.td}ddi}|||d|ddS)Nzdata = [] bar = foo r%r0r$rr1rrr2rvrrrtest_internal_shadowing.s z%SuiteTestCase.test_internal_shadowingcC*td}i}|||d|ddS)Nr0r0r%r3r4rrr test_assign;s zSuiteTestCase.test_assigncCs8td}i}||d|vsJ|d|ddS)Nzdef donothing(): pass donothingr3r4rrrtest_defAs   zSuiteTestCase.test_defcCs<td}ddi}||d|vsJ|d|ddS)Nz2 def donothing(): if True: return foo r%r$r8r3r4rrr!test_def_with_multiple_statementsHs   z/SuiteTestCase.test_def_with_multiple_statementscC.td}i}|||ddg|ddS)Nzl values = [] def add(value): if value not in values: values.append(value) add('foo') add('bar') r%r$r%r3r4rrrtest_def_using_nonlocalS z%SuiteTestCase.test_def_using_nonlocalcC:td}i}|||d|d|d|ddS)NzY def difference(v1, v2=10): return v1 - v2 x = difference(20, 19) y = difference(20) r>rB rMr3r4rrrtest_def_some_defaults`  z$SuiteTestCase.test_def_some_defaultscCsJtd}i}|||d|d|d|d|d|ddS)Nzn def difference(v1=100, v2=10): return v1 - v2 x = difference(20, 19) y = difference(20) z = difference() r>rBr?rMZzr3r4rrrtest_def_all_defaultsls  z#SuiteTestCase.test_def_all_defaultscCr6)Nzj def mysum(*others): rv = 0 for n in others: rv = rv + n return rv x = mysum(1, 2, 3) rrBr3r4rrrtest_def_varargzs zSuiteTestCase.test_def_varargcCs2td}i}|||ddgt|ddS)Nz^ def smash(**kw): return [''.join(i) for i in kw.items()] x = smash(foo='abc', bar='def') bardeffooabcrB)rr1rsortedr4rrrtest_def_kwargss zSuiteTestCase.test_def_kwargscCr6)Nz8 def kwonly(*args, k): return k x = kwonly(k="foo") r%rBr3r4rrrtest_def_kwonlyarg z SuiteTestCase.test_def_kwonlyargcCr>)NzK def kwonly(*args, k="bar"): return k x = kwonly(k="foo") y = kwonly() r%rBr$rMr3r4rrrtest_def_kwonlyarg_with_defaultrAz-SuiteTestCase.test_def_kwonlyarg_with_defaultcCr;)Nz def doit(): values = [] def add(value): if value not in values: values.append(value) add('foo') add('bar') return values x = doit() r%r$rBr3r4rrrtest_def_nesteds zSuiteTestCase.test_def_nestedcCr6)Nzl def lower(fun): return lambda: fun().lower() @lower def say_hi(): return 'Hi!' result = say_hi() zhi!resultr3r4rrrtest_def_with_decorators z%SuiteTestCase.test_def_with_decoratorcCs&td}i}||d|vsJdS)Nzfoo = 42 del foo r%rr1r4rrr test_deletes zSuiteTestCase.test_deletecC&td}i}||d|vsJdS)Nzclass plain(object): passplainrPr4rrr test_class zSuiteTestCase.test_classcCs.td}i}|||dt|ddS)Nz def create(): class Foobar(object): def __str__(self): return 'foobar' return Foobar() x = create() r#rB)rr1rrr4rrrtest_class_in_defr=zSuiteTestCase.test_class_in_defcCrR)Nz7class plain(object): def donothing(): pass rSrPr4rrrtest_class_with_methodss z%SuiteTestCase.test_class_with_methodscCrR)Nzfrom itertools import repeatrepeatrPr4rrr test_importrUzSuiteTestCase.test_importcCs(td}t}||d|vsJdS)Nzfrom itertools import *rX)rrr1r4rrrtest_import_stars zSuiteTestCase.test_import_starcCsBtd}t}||d|vsJ|gdt|ddS)NzDdef fun(): from itertools import repeat return repeat(1, 3) rX)r>r>r>fun)rrr1rrr4rrrtest_import_in_defs   z SuiteTestCase.test_import_in_defcCs.td}i}|||gd|ddS)Nz-x = [] for i in range(3): x.append(i**2) )rr>rUrBr3r4rrrtest_fors zSuiteTestCase.test_forcCs8td}i}||d|vsJ|d|ddS)NzVdef loop(): for i in range(10): if i == 5: break return i looprr3r4rrrtest_for_in_def s   zSuiteTestCase.test_for_in_defcC.td}ddi}|||d|ddS)Nzif foo == 42: x = True r%r0TrBr3r4rrrtest_ifs zSuiteTestCase.test_ifcCstd}|t|jidS)Nzraise NotImplementedError)rrrr1rr2rrr test_raiseszSuiteTestCase.test_raisecC*td}i}|||d|ddS)NzXtry: import somemod except ImportError: somemod = None else: somemod.dosth()somemodr3r4rrrtest_try_except"s zSuiteTestCase.test_try_exceptcCrd)Nz%try: x = 2 finally: x = None rBr3r4rrr test_finally-rKzSuiteTestCase.test_finallycCr`)Nz>x = 0 while x < 5: x += step if x == 4: break steprrUrBr3r4rrrtest_while_break7s zSuiteTestCase.test_while_breakcC2td}ddi}|d|i|d|ddS)Nz d['k'] += 42kr>d+r3rr2rlrrr#test_augmented_attribute_assignmentBz1SuiteTestCase.test_augmented_attribute_assignmentcCstdidS)Nzx = 1; x += 42; assert x == 43rPr'rrrtest_local_augmented_assignHsz)SuiteTestCase.test_local_augmented_assigncC&i}td||d|ddS)Nz6def foo(): i = 1 i += 1 return i x = foo()rrBr3rrlrrrtest_augmented_assign_in_defKsz*SuiteTestCase.test_augmented_assign_in_defcCrr)NzQdef foo(): i = 0 for n in range(5): i += n return i x = foo()r?rBr3rsrrr$test_augmented_assign_in_loop_in_defTsz2SuiteTestCase.test_augmented_assign_in_loop_in_defcCrj)Nz)[d['k']] = 'foo',; assert d['k'] == 'foo'rkr$rlr%r3rnrrrtest_assign_in_list^rpz!SuiteTestCase.test_assign_in_listcCstd}|dddiidS)Nz&x = 1; exec(d['k']); assert x == 42, xrlrkzx = 42rPrbrrr test_execdr*zSuiteTestCase.test_execcCstd}|ddidS)Nz) def f(): return v assert f() == 42 rr0rPrbrrr test_returnhszSuiteTestCase.test_returncCs2td}dii}|||d|dddS)Nzd['k'] = 'foo'rlr%rkr3r4rrrtest_assign_to_dict_itemqs z&SuiteTestCase.test_assign_to_dict_itemcCsBGdddt}|}td}d|i}|||d|jdS)Nc@s eZdZdS)z9SuiteTestCase.test_assign_to_attribute..SomethingN)rrrrrrrrxs rzobj.attr = 'foo'rr%)rrr1rattr)rrrr2rvrrrtest_assign_to_attributews  z&SuiteTestCase.test_assign_to_attributecCs<Gdddt}|}tdd|i|t|ddS)Nc@r)z-SuiteTestCase.test_delattr..SomethingcSr)Nr%)rzr'rrrrrz6SuiteTestCase.test_delattr..Something.__init__Nrrrrrrrrz del obj.attrrrz)rrr1 assertFalsehasattr)rrrrrr test_delattrszSuiteTestCase.test_delattrcCs*ddi}tdd|i|d|dS)Nrkr%z del d['k']rl)rr1 assertNotInrsrrr test_delitemszSuiteTestCase.test_delitemc Cs~t\}}t|d}z-|d|d|d|i}td}|||ddg|dWt |dSt |w) Nwzfoo bar rpathz{from __future__ import with_statement lines = [] with open(path) as file: for line in file: lines.append(line) foo zbar lines rosfdopenwritercloserr1rremoverfdrrrlr2rrrtest_with_statements     z!SuiteTestCase.test_with_statementcCs.i}td}|||gd|ddS)Na  results = [] def counter(maximum): i = 0 while i < maximum: val = (yield i) if val is not None: i = val else: i += 1 it = counter(5) results.append(next(it)) results.append(it.send(3)) results.append(next(it)) )rr?rUresultsr3)rrlr2rrrtest_yield_expressions z#SuiteTestCase.test_yield_expression)r?r?c Cs~t\}}t|d}z-|d|d|d|i}td}|||ddg|dWt |dSt |w)Nrrrrzfrom __future__ import with_statement lines = [] with open(path) as file1, open(path) as file2: for line in file1: lines.append(line) for line in file2: lines.append(line) rrrrrr'test_with_statement_with_multiple_itemss     z5SuiteTestCase.test_with_statement_with_multiple_itemscCs6td}dgdi}|||ddg|ddS)Nzx = numbers[0:2]rrrr>rBr3r4rrrr  zSuiteTestCase.test_slicecCs:td}gdddd}|||ddg|ddS)Nzx = numbers[start:end]rrrrr>rBr3r4rrrrs z"SuiteTestCase.test_slice_with_varscCs6td}dgdi}|||gd|ddS)Nzx = numbers[:]rrrBr3r4rrrrrzSuiteTestCase.test_slice_copycC8td}gddd}|||gd|ddS)Nzx = numbers[::stride]rrrrrBr3r4rrrr zSuiteTestCase.test_slice_stridecCs6td}gddd}|||dg|ddS)Nzx = numbers[-1:]rrrrUrBr3r4rrrrs z'SuiteTestCase.test_slice_negative_startcCr)Nzx = numbers[:-1]rrrrrBr3r4rrrrrz%SuiteTestCase.test_slice_negative_endcCs2td}dgdi}|||d|ddS)Nzx = numbers[1]rrr>rBr3r4rrrrs  z!SuiteTestCase.test_slice_constantcCs<dd}td}gd|d}|||d|ddS)NcSrprrrrrrrr~z(SuiteTestCase.test_slice_call..fzx = numbers[f()]rrrrBr3)rrr2rvrrrrs  zSuiteTestCase.test_slice_callcCs4td}gddd}|||d|ddS)Nzx = numbers[v]rrrrBr3r4rrrrs zSuiteTestCase.test_slice_namecCsDGddd}td}gd|d}|||d|ddS)Nc@r)z7SuiteTestCase.test_slice_attribute..ValueHoldercSrrrr'rrrrrz@SuiteTestCase.test_slice_attribute..ValueHolder.__init__Nrrrrrrrrzx = numbers[obj.value]rrr?rBr3)rrr2rvrrrrs  z"SuiteTestCase.test_slice_attributeN):rrrr#r5r7r9r:r<r@rDrErIr rJrLrMrOrQrTrVrWrYrZr\r]r_rarcrfrgrirorqrtrurvrwrxryr{r~rrrrhr.rrrrrrrrrrrrrrrr/!sn                      r/cCsBt}|ttj|ttd|tt d|S)Ntest) unittest TestSuiteaddTestdoctest DocTestSuiterr makeSuiter r/)r2rrrr2 s r2__main__) defaultTest)rrrrhtempfilerr genshi.corergenshi.template.basergenshi.template.evalrrrrr genshi.compatr r r TestCaser r/r2rmainrrrrs.     o