mock with inheritance

lidiriel ludovic.mercier at gmail.com
Wed Jul 9 06:54:53 EDT 2008


Hello,

i would like use a mock object for testing one class and its methods:
Here my class :
class Foo(Component):
    def __init__(self):
        self._db = self.env.get_db()

    def foomethod(self, arg):
       .....

But i don't know how to mock the class Component. Note that Component
provide the attribut env.
I use
Pyhton mock module (author Dave Kirby's ) or
mock (author Michael Foord (fuzzyman)) but if you have a generic
solution i will adapt it to my problem.

Thanks by advance and sorry for my poor english.




More information about the Python-list mailing list