H
HMS Surprise
I am trying to understand the 'if' statement and the exec statement in
the code below. I would like to add several common routines to this
class and then inherit it into a class in another file. This other
class would need to access these common functions as well as inherit
the PyHttpTestCase class. In particular what is the purpose of the
surrounding plus signs? May I assume the if statement overrides an
imported assignment statement.
Thanks,
jh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
if __name__ == 'main':
validatorPkg = Config.getValidatorPkgName()
# Determine the validator for this testcase.
exec 'from '+validatorPkg+' import Validator'
# definition of test class
class baseClass(PyHttpTestCase):
def logon()
print 'logon()'
def runTest(self):
print 'runTest()'
def myFn(self):
print 'myFn()'
# Code to load and run the test
if __name__ == 'main':
test = baseClass("bClass")
test.runTest()
the code below. I would like to add several common routines to this
class and then inherit it into a class in another file. This other
class would need to access these common functions as well as inherit
the PyHttpTestCase class. In particular what is the purpose of the
surrounding plus signs? May I assume the if statement overrides an
imported assignment statement.
Thanks,
jh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
if __name__ == 'main':
validatorPkg = Config.getValidatorPkgName()
# Determine the validator for this testcase.
exec 'from '+validatorPkg+' import Validator'
# definition of test class
class baseClass(PyHttpTestCase):
def logon()
print 'logon()'
def runTest(self):
print 'runTest()'
def myFn(self):
print 'myFn()'
# Code to load and run the test
if __name__ == 'main':
test = baseClass("bClass")
test.runTest()