-
-
Save cjw296/db64279c69cdc0c5e112 to your computer and use it in GitHub Desktop.
Current test with method() workaround, where I would like to use C1.meth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_classes(self): | |
m = Mock() | |
class T0(object): pass | |
class T1(object): pass | |
class T2(object): pass | |
t1 = T1() | |
t2 = T2() | |
class C1(object): | |
def __init__(self): | |
m.C1.__init__() | |
def meth(self): | |
m.C1.method() | |
return t1 | |
@requires(T1) | |
class C2(object): | |
def __init__(self, obj): | |
m.C2.__init__(obj) | |
@requires(T0) | |
def meth1(self): | |
m.C2.method() | |
return t2 | |
@requires(T2) | |
def meth2(self, obj): | |
m.Base.parse(obj) | |
class C3(object): | |
@requires(T2) | |
def __call__(self, obj): | |
m.C3.__call__(obj) | |
runner = Runner( | |
# no need for the decorator for simple instantiation | |
T0, | |
method(C1, 'meth'), | |
method(C2, 'meth1'), | |
method(C2, 'meth2'), | |
) | |
runner.add(method(C3)) | |
runner() | |
compare([ | |
call.job1(), | |
call.job2(t1, t2), | |
], m.mock_calls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment