Skip to content

Instantly share code, notes, and snippets.

@cjw296
Created July 4, 2013 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjw296/db64279c69cdc0c5e112 to your computer and use it in GitHub Desktop.
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
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