【发布时间】:2015-04-01 09:20:50
【问题描述】:
问题
如何通过super() 调用测试从另一个超类继承的类及其方法?
示例
class A():
def __init__(self, x, y):
# do something with x and y
def aMethod(self, param1):
# do stuff with param1
class B(A):
def bMethod1(self, param2):
# do stuff with self and param2
super(B, self).aMethod(param2)
def bMethod2(self, myDict):
# do stuff with myDict
return myDict
如果我有例如class A(Z)(继承自class Z())然后是class B(A),会不会一样?
这个answer 和我要找的很相似,但它是用来模拟的!
编辑
所以我的鼻子测试会有这样的东西:
class Test_B(Object):
# All of the setup and teardown defs go here...
def test_bMethod2(self):
b = B()
dict = { 'a' : '1', 'b' : '2' } # and so on...
assert_equal(b.bMethod2(dict), dict)
【问题讨论】:
标签: python inheritance nose