On 09/01/2011 19:53, Dave Angel wrote:
On 01/-10/-28163 02:59 PM, Ian Hobson wrote:
Hi all,

I am trying to develop a PyQt application, and I want to unittest it.

snip
D:\work\ian>python testAll.py
E
======================================================================
ERROR: test001_walkingSkeleton (testCubic.testCubic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\work\ian\testCubic.py", line 8, in test001_walkingSkeleton
app.processEvents() # fails
NameError: global name 'app' is not defined


You have two global variables called app, one is in the testCubic module and the other is in the testAll.py script. They do not automatically refer to the same thing.

To use a global from another module, you can either do an import, or you can pass it as an argument. But beware of mutual imports.

DaveA

Thanks David, I found http://mail.python.org/pipermail/tutor/2002-November/018353.html and
created a shared module that both modules can import.

Then I refer to shared.app, no use of global and it works as desired.

I am on to the next step - actually running my code.

Regards
Ian



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to