Код: Выделить всё
from external_library import GenericClass
class SpecificClass(GenericClass):
def __init__(self, a, b, c):
super(SpecificClass, self).__init__(a, b)
self.c = c
def specific_method(self, d):
self.initialize()
return d + self.c + self.b + self.a.fetch()
Код: Выделить всё
GenericClass
Код: Выделить всё
external_library
Код: Выделить всё
class GenericClass(object):
def __init__(self, a, b):
self.a = a
self.b = b + "append"
def initialize(self):
# it might be an expensive operation
self.a.initialize()
def specific_method(self, d):
raise NotImplementedError
Пожалуйста, используйте макет в качестве библиотеки макетов и pytest в качестве тестовой среды. Решение должно быть совместимо с Python2.6+.
Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/279 ... or-testing