Importing

HMS Surprise john at datavoiceint.com
Fri Mar 16 14:33:21 CET 2007


Greetings,

First I will admit I am new to Python but have experience with C++ and
some Tcl/Tk. I am starting to use a tool called MaxQ that  uses
jython. I have been studying Rossum's tutorial but still am unclear on
importing, the use of self, and calling functions with their own name
in quotes. In the code below the lines between #Start and #End are
generated by browsing web pages. In a large test this section can
become quite large. The maxQ documentation suggests breaking it up
into functions. If so could these functions be placed in a separate
file and imported? Is it acceptable to import into a class? If
imported as a function will self as used here need to be changed?
Would it be better to duplicate class and import whole classes?

Any suggestions will be appreciated, especially other Python
tutorials.

Best Regards,

jh

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Generated by MaxQ
[com.bitmechanic.maxq.generator.JythonCodeGenerator]
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 MaxQTest(PyHttpTestCase):
    def runTest(self):
        self.msg('Test started')

    #Start

        self.msg("Testing URL: %s" % self.replaceURL('''http://
www.dogpile.com/'''))
        url = "http://www.dogpile.com/"
        params = None
        Validator.validateRequest(self, self.getMethod(), "get", url,
params)
        self.get(url, params)
        self.msg("Testing URL: %s" % self.replaceURL('''http://
www.dogpile.com/favicon.ico'''))
        url = "http://www.dogpile.com/favicon.ico"
        params = None
        Validator.validateRequest(self, self.getMethod(), "get", url,
params)
        self.get(url, params)

    #End

    # ^^^ Insert new recordings here.  (Do not remove this line.)


# Code to load and run the test
if __name__ == 'main':
    test = MaxQTest("MaxQTest")


#   test.Run()		#Either of these two lines work equally well.
    test.runTest()	#I suspect that Run() is a method of
PPyHttpTestCase or a builtIn




More information about the Python-list mailing list