By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,985 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,985 IT Pros & Developers. It's quick & easy.

cannot import name .....

P: n/a

Greetings.

What is the implication of the error message 'cannot import
name .....'? It occurs when executing the line:

from nBaseTest import nBaseTest

The file exists and the class within it exists. Changing it to

from nBaseTest import x

gives me the same result so it is as though the class does not exist.
Thought there may be a problem with the nBaseTest file but standalone
it runs fine.

Thus my earlier question. Maybe I should ask where find detailed error
information.

Thanks,

jvh

May 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thanks for posting.

pythonpath = .;c:\maxq\bin\testScripts; c:\maxq\bin;c:\maxq\jython

Both files are in c:\maxq\bin\testScripts. Also I do not get the
message "no module named...:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File nCreateIncident.py, the importer:

from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
from nBaseTest import nBaseTest

# definition of test class
class nCreateIncident(nBaseTest):
def runTest(self):
self.msg('Test started')
self.logon()

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File nBaseTest

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 nBaseTest(PyHttpTestCase):
def logon(self):
self.msg('Test started')

if __name__ == 'main':
t = nBaseTest('nBaseTest')
t.logon()

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

Best Regards,

jvh

May 3 '07 #2

P: n/a
I do see one problem there...

if __name__ == 'main':
t = nBaseTest('nBaseTest')
t.logon()

That should be:

if __name__ == "__main__":
t = nBaseTest('nBaseTest')
t.logon()

It should be like that in both files.

May 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.