I've got a set of tests, and I've found that I'm copying/pasting a lot of code from class to class, so I want to make a base class to remove this.
To do this effectively, I need to make the module-under-test's function to call be accessible to the base class. It seems like it should be simple to do, but what I've found is that if my child class specifies a global variable that is the function to test, the base class, when it calls it, inserts 'self' as parameter zero, resulting in TypeError: FooBar() takes exactly 2 arguments (3 given)
My Code:
import unittest
import moduleOfFunctionsToTest as uut
class Base_Test_Class( unittest.TestCase ):
def setUp( self ):
# Common test suite setup
return
def runFcn( self ):
return self.uutFcn( "foo", self.bar )
# other common fucntions.
class TheFirstTestClass( Base_Test_Class ):
uutFcn = uut.FooBar
bar = "0"
def test_SomeCode( self ):
self.runFcn
How can I call self.uutFcn
without self
being inserted? I've tried passing the value via a constructor, but that caused other headaches (which I may need to revisit if that is correct path to take.)
TIA!