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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -