|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Cannot use module "re", why not?I need to use regular expressions. So I tried to import it:
import re But when running, it says: Traceback (innermost last): File "<string>", line 2, in ? ImportError: no module named re What is the problem here? I read that the module "re" is contained in Jython. If I don't import it, I get another error: Traceback (innermost last): File "<string>", line 27, in ? File "<string>", line 13, in runTest NameError: re Any solution?
We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. |
|
|
Re: Cannot use module "re", why not?> I need to use regular expressions. So I tried to import it:
> > import re > ... > What is the problem here? I read that the module "re" is contained > in Jython. If I don't import it, I get another error: The MaxQ distribution includes only the base Jython JAR file. If you want the libraries then see the section "Using the Full Jython Libraries" under Recipes in the command line. Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Creating a base classI have tried unsuccessfully to create a base class using a standard script.
I want to put all the functions I use most often in this base class. In th file main.py below I have done nothing but change the import class to baseClass and added a calle to logon. The first time I run it I get the error: NameError: validatorPkg The second time I run it (after a baseClass class file is generated) I get the error: ImportError: cannot import name baseClass I experimented with other jython scripts and have been able to do this. I don't understand all that is going on with the first 8 lines of the standard script and I suspect that this has something to do with it. I am guessing that those lines are not executed when I try to import from the baseClass file. I also tried moving those lines (except the if) inside the class to no avail. Ideas? Thanks, John ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ File main.py # 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' from baseClass import baseClass # definition of test class class main(baseClass): def runTest(self): self.msg('Test started') self.logon() # ^^^ Insert new recordings here. (Do not remove this line.) # Code to load and run the test if __name__ == 'main': test = main("main") test.Run() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ File baseClass.py # 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 baseClass(PyHttpTestCase): def logon(self): self.msg('Logon.') # ^^^ Insert new recordings here. (Do not remove this line.) # Code to load and run the test if __name__ == 'main': test = baseClass("baseClass") test.logon() --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Creating a base classJohn,
I cannot quite remember what the Validator stuff does. I think I tried to get rid of it at one stage, but met with some resistance. I recommend the Compact base class instead. Anyway, I'm sure you don't want the Validator stuff in both base class and your script class. I'd try removing it from your base class file. Also, you don't need the >> if __name__ == 'main': in your base class. It is boilerplate code that instantiates the test object in your script class. The base class instance will be automatically created as part of this process. Oliver -- On 23/05/2007, at 01:23, jh wrote: > I have tried unsuccessfully to create a base class using a > standard script. I want to put all the functions I use most often > in this base class. In th file main.py below I have done nothing > but change the import class to baseClass and added a calle to > logon. The first time I run it I get the error: > > NameError: validatorPkg > > The second time I run it (after a baseClass class file is > generated) I get the error: > > ImportError: cannot import name baseClass > > I experimented with other jython scripts and have been able to do > this. I don't understand all that is going on with the first 8 > lines of the standard script and I suspect that this has something > to do with it. I am guessing that those lines are not executed when > I try to import from the baseClass file. I also tried moving those > lines (except the if) inside the class to no avail. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |