Help needed with unittest and global

I

Ian Hobson

Hi all,

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

After three false starts, I am plainly unaware of something rather basic
- can some kind person please help me out?

This is a log to show what I have so far
D:\work\ian>type testAll.py
# coding=utf8
# testAll.py - run all tests.
import unittest
import sys
from PyQt4.QtGui import *
from testCubic import testCubic
global app
def main():
suite = unittest.TestLoader()
suite.loadTestsFromTestCase(testCubic)
unittest.TextTestRunner().run(suite)
if __name__=="__main__":
global app
app = QApplication(sys.argv) # set gloabl app
unittest.main()

D:\work\ian>type testCubic.py
# coding=utf8
# testCubic.py - tests the top level module
import unittest
global app
class testCubic(unittest.TestCase):
def test001_walkingSkeleton(self):
global app # use global version
app.processEvents() # fails
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

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

D:\work\ian>

Thanks

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top