unittest2 - Python unittest: how to use setUpClass() and tearDownClass() with arguments -
i use python unittest setupclass , teardownclass methods arguments. more specifically, here doing now:
import unittest2 unittest cache = vcache(arg1, arg2, arg3) class validation(unittest.testcase): ''' unit test class local cache avoid intensive network traffic. ''' @classmethod def setupclass(cls): ''' copy required data locally. ''' super(validation, cls).setupclass() cache.setup() @classmethod def teardownclass(cls): ''' remove cache. ''' super(validation, cls).teardownclass() cache.teardown()
it works wrap cache management in subclass of validation, avoid using global variable , writing setupclass , teardownclass everytime.
this not work of course because setupclass() , teardownclass() not accept arguments. solution?
Comments
Post a Comment