I need to run a Python unittest test suite against multiple REST backend resources so I need to pass in a Resource object to the test suite and individual testcases.
Is setting a global var the right way to do this, or is there a better way?
resource = Resource(‘http://example.com’)
class RestTestCase(unittest.TestCase):
def setUp(self):
self.resource = resource
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(RestTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
Follow the example of the how the standard library writes its own unittests. Put the resource in a class variable and use inheritance to test the various resources: