Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyc

ó
ê=Nc@sVdZddlmZddlmZdd	d„ƒYZdejfd„ƒYZdS(
s%
Tests for L{twisted.python.monkey}.
iÿÿÿÿ(tunittest(t
MonkeyPatchertTestObjcBseZd„ZRS(cCsd|_d|_d|_dS(Ns	foo values	bar values	baz value(tfootbartbaz(tself((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt__init__
s		(t__name__t
__module__R(((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyRstMonkeyPatcherTestcBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
RS(s;
    Tests for L{MonkeyPatcher} monkey-patching class.
    cCs(tƒ|_tƒ|_tƒ|_dS(N(Rt
testObjecttoriginalObjectRt
monkeyPatcher(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pytsetUpscCse|jjƒ|j|jj|jjƒ|j|jj|jjƒ|j|jj|jjƒdS(sL
        A monkey patcher without patches shouldn't change a thing.
        N(R
tpatchtassertEqualRRRRR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt
test_emptys
cCs}t|jddf|jddfƒ}|jƒ|jd|jjƒ|jd|jjƒ|j|jj|jjƒdS(s}
        Constructing a L{MonkeyPatcher} with patches should add all of the
        given patches to the patch list.
        RthahaRtheheN(RRRRRRRR(Rtpatcher((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_constructWithPatches+s
cCs@|jj|jddƒ|jjƒ|j|jjdƒdS(sf
        Patching an attribute that exists sets it to the value defined in the
        patch.
        RRN(R
taddPatchRRRR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_patchExisting8s
cCs3|jj|jddƒ|jt|jjƒdS(sT
        Patching a non-existing attribute fails with an C{AttributeError}.
        tnowheresblow up pleaseN(R
RRtassertRaisestAttributeErrorR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_patchNonExistingBscCs‚|jj|jddƒ|jj|jddƒ|jjƒ|j|jjdƒ|jjƒ|j|jj|jjƒdS(s|
        Adding a patch for an object and attribute that already have a patch
        overrides the existing patch.
        RtblahtBLAHN(R
RRRRRtrestoreR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_patchAlreadyPatchedKs

cCs||jj|jddƒ|jjƒ|jjƒ|j|jj|jjƒ|jjƒ|j|jj|jjƒdS(sH
        Restoring an already-restored monkey patch is a no-op.
        RRN(R
RRRRRRR(R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_restoreTwiceIsANoOpXs


cs]g‰d‡fd†}|jj|ddddƒ}|jd|ƒ|jdgˆƒdS(	s¤
        runWithPatches should run the given callable, passing in all arguments
        and keyword arguments, and return the return value of the callable.
        csˆj|||fƒdS(NR(tappend(tatbtc(tlog(s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pytfksiiR$i
RN(iii
(tNoneR
trunWithPatchesR(RR&tresult((R%s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_runWithPatchesDecorationds
csš‡fd†}ˆjjˆjddƒˆjj|ƒ}ˆjdˆjjˆjjf|ƒˆjj|ƒ}ˆjdˆjjˆjjf|ƒdS(s‘
        We should be able to call the same function with runWithPatches more
        than once. All patches should apply for each call.
        csˆjjˆjjˆjjfS(N(RRRR((R(s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyR&ysRRN(R
RRR(RRRR(RR&R)((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_repeatedRunWithPatchestscCsh|jj|jddƒ|j|jj|jjƒ|jjd„ƒ|j|jj|jjƒdS(so
        C{runWithPatches} should restore the original values after the function
        has executed.
        RRcSsdS(N(R'(((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt<lambda>ŽsN(R
RRRRRR((R((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyttest_runWithPatchesRestores‡scs–‡fd†}ˆjjˆjddƒˆjjˆjddƒˆjtˆjj|ƒˆjˆjjˆjjƒˆjˆjj	ˆjj	ƒdS(sv
        Test runWithPatches restores the original values even when the function
        raises an exception.
        cs9ˆjˆjjdƒˆjˆjjdƒtd‚dS(NRtblahblahsSomething went wrong!(RRRRtRuntimeError((R(s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt_—sRRRR.N(
R
RRRR/R(RRRR(RR0((Rs</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt&test_runWithPatchesRestoresOnException’s(RR	t__doc__RRRRRRR R*R+R-R1(((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyR
s		
	
	
			
				N((R2t
twisted.trialRttwisted.python.monkeyRRtTestCaseR
(((s</usr/lib/python2.7/dist-packages/twisted/test/test_monkey.pyt<module>s