468,304 Members | 1,430 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,304 developers. It's quick & easy.

cannot import name .....


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
2 12138
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
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.

Similar topics

2 posts views Thread by Marc Ederis | last post: by
1 post views Thread by yazzoo | last post: by
3 posts views Thread by geir.smestad | last post: by
10 posts views Thread by Jia Lu | last post: by
3 posts views Thread by srig | last post: by
reply views Thread by Anna Butt | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.