actually this is my code
import statements
class mrp_repair_test_case(unittest.TestCase):
def __init__(self, cursor=None, user=None, methodName='runTest'):
unittest.TestCase.__init__(self,methodName)
self.uid = user
self.cr = cursor
def setUp(self):
try:
self.pool = pooler.get_pool(cr.dbname)
self.repair_order = self.pool.get('mrp.repair')
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def tearDown(self):
try:
self.pool = None
self.repair_order = None
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_1_Create(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_2_ConfirmRepair(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_3_RepairReady(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_4_RepairStart(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_4_RepairEnd(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_5_PrintProductionOrder(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_6_MakeInvoice(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_7_CancelProductionOrder(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def test_8_Unlink(self):
try:
except osv.except_osv,e:
self.fail(e.name + e.value)
except Exception,e:
self.fail(e)
def runTest(cursor=None, user=None):
global cr
global uid
cr = cursor
uid = user
out = StringIO()
testmethods = unittest.TestLoader().getTestCaseNames(mrp_repair_test_case)
for test in testmethods:
mrp_repair_test_case(cursor=cursor,user=user,methodName=test)
m = mrp_repair_test_case(cursor=cursor,user=user)
suite = unittest.TestLoader().loadTestsFromTestCase(m)
res = unittest.TextTestRunner(stream=out,verbosity=2).run(suite)
if res.wasSuccessful():
return (True,out.getvalue())
print out.getvalue()
return (res,out.getvalue())
this runTest() will be called by third party module and that third party will pass the cursor and user so what I want is this cursor and user in all my testcases. but I am not able to do so. same case is taht If we need a value of a variable in other testcase that is created in one test case we need to define that variable as global then and then we can use it but I dont want to use global I want to assign it in self using init
How can I .
Thanks for your quick response
Edit:1 :
thanks for your response but can I get by overriding unittest case init() if yes then how ?