python - Nose test superclass calls and inherited classes -


question
how may test class , methods has inherited superclass through super() call?

example

class a():     def __init__(self, x, y):         # x , y      def amethod(self, param1):         # stuff param1  class b(a):     def bmethod1(self, param2):         # stuff self , param2         super(b, self).amethod(param2)      def bmethod2(self, mydict):         # stuff mydict         return mydict 

and same if had example, class a(z) (inheritance class z()) , class b(a) ?

this answer similar i'm looking for, it's mocking!

edit
have nose test:

class test_b(object):     # of setup , teardown defs go here...     def test_bmethod2(self):         b = b()         dict = { 'a' : '1', 'b' : '2' } # , on...         assert_equal(b.bmethod2(dict), dict) 

a way of doing is:

class test_b(object): # of setup , teardown defs go here... def test_bmethod2(self):     a, b, param = "",     dict = { 'a' : '1', 'b' : '2' }     # instantiating b super params     klass = b(a, b)     # calling class b's bmethod1() required params      # pass onto super class' method (here: amethod())     klass.bmethod1(param)     assert_equal(klass.bmethod2(dict), dict) 

hope helps else.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -