鼻子测试超类调用和继承类

Nose test superclass calls and inherited classes

问题
我如何测试 class 及其通过 super() 调用从另一个 Superclass 继承的方法?

示例

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 与我正在寻找的非常相似,但它是用于 Mocking 的!

编辑
所以我的鼻子测试会有这样的东西:

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)

一种方法是:

class Test_B(Object):
# All of the setup and teardown defs go here...
def test_bMethod2(self):
    a, b, param = "",
    dict = { 'a' : '1', 'b' : '2' }
    # Instantiating B with its super params
    klass = B(a, b)
    # Calling class B's bMethod1() with required params 
    # to pass onto its super class' method (here: aMethod())
    klass.bMethod1(param)
    assert_equal(klass.bMethod2(dict), dict)

希望这对其他人有帮助。