C
Chris Smith
Sumit> I have scinario like I have to Create resource(in
Sumit> __init__()) Before Running a set of testcases and then In
Sumit> Testcases resources are going to used and then It will
Sumit> cleared off after Running the testcases by destructor
Sumit> __del__() import unittest import time
Sumit> class app_adminfunc(unittest.TestCase):
Sumit> def __init__(self, method = 'runTests'):
Sumit> unittest.TestCase.__init__(self, method)
Sumit> #------------Resource Creation --------
Sumit> def __del__(self): #--------------Resource
Sumit> Deletion -----------------
Sumit> def test01----- def test02----- ....... ....
Sumit> But in this above code Problem is that __init__() called at
Sumit> each time when the Testcase is run ,But i want Single time
Sumit> run of the Init Prior to run of each tests inside the class
Sumit> . Can Anybody help me on this ?
The unittest module runs a setUp and tearDown before each test case.
If that is too high-frequency, why not just do something like
class app_adminfunc(unittest.TestCase):
def setUp(self): pass
def tearDown(self): pass
def allYourTestCase(self):
def test01(): pass
def test02(): pass
since python is so mellow about nesting functions and classes and
such.
HTH,
Chris
Sumit> __init__()) Before Running a set of testcases and then In
Sumit> Testcases resources are going to used and then It will
Sumit> cleared off after Running the testcases by destructor
Sumit> __del__() import unittest import time
Sumit> class app_adminfunc(unittest.TestCase):
Sumit> def __init__(self, method = 'runTests'):
Sumit> unittest.TestCase.__init__(self, method)
Sumit> #------------Resource Creation --------
Sumit> def __del__(self): #--------------Resource
Sumit> Deletion -----------------
Sumit> def test01----- def test02----- ....... ....
Sumit> But in this above code Problem is that __init__() called at
Sumit> each time when the Testcase is run ,But i want Single time
Sumit> run of the Init Prior to run of each tests inside the class
Sumit> . Can Anybody help me on this ?
The unittest module runs a setUp and tearDown before each test case.
If that is too high-frequency, why not just do something like
class app_adminfunc(unittest.TestCase):
def setUp(self): pass
def tearDown(self): pass
def allYourTestCase(self):
def test01(): pass
def test02(): pass
since python is so mellow about nesting functions and classes and
such.
HTH,
Chris