Hi,
I’m having trouble coordinating the unittests of my wxpython app. I have two test files with essentially the same layout:
# — test mod layout ---- #
class MyApp(wx.App):
def OnInit(self):
self.frame = wx.Frame(None)
return True
class test_RunGUITests(unittest.TestCase):
def setUp(self):
self.app = MyApp(redirect=False)
self.frame = AppFrame(None, title='Accounter')
… Run tests…
def tearDown(self):
self.frame.Destroy()
wx.GetApp().ExitMainLoop()
I then have a file used to execute specified test modules:
# — script used to start the tests — #
if name = ‘main’
tests = {0: ‘path/to/testmod1’,
1: ‘path/to/testmod2’}
to_run = [0,1]
for each in to_run:
nose.run(argv=["w", "-s", testmods[each]])
Both modules run with no problems If I execute them individually, (e.g. set to_run = [1]). However if I try to run them one after the other (to_run = [0,1]) one of the tests in the module being run in second place always fails with the excpetion: PyNoAppError: The wx.App object must be created first!
Having experimented for the last couple of hours I’m no closer to understanding what’s going on. My hunch is that I’m not clearing up my app objects correctly, but I can’t rule out the possibility that the problem is something to do with the workings of nose and/or unittest. Does any one have any ideas?