Testing GUI application using pygobject3 with pytest problem



(Please note I already posted this question at Stack Overflow: 
https://stackoverflow.com/questions/22715241/testing-gui-application-using-pygobject3-with-pytest )

I got a task to write some unit tests for devassistant (a helper program can help you set up your developing 
environment). It is written in Python and offers graphical user interface which is implemented with 
pygobject3. There are already unit tests, using pytest.
I wrote some basic tests, which work like this:

- create the main window (like the application was executed normally by a human) but do not call Gtk.main() - 
so that the main window won't show up
- simulate interactions with gui (clicking buttons, un/tinking checkboxes etc) or directly call their 
callbacks
- check if things are as expected (call asserts)

The actual problem is, that when the gui tests are passed and there are more tests after the gui tests, 
during doing the following tests an empty window (with just a title) shows up and pytest freezes (the empty 
window does't react and cannot be closed), so I must kill it. If I "move" the gui tests to the last position, 
they work normally.

Steps to reproduce:

- clone my repository https://github.com/jkoncick/devassistant - the actual commit adding the tests is 
https://github.com/jkoncick/devassistant/commit/e4296fcf7e1393a1140f3205304e54b9e8c62375
- (install all required python packages - they are in the requirements file)
- move the test_gui.py file into parent directory - so that the gui tests are not performed last but there 
are some tests after them
- in devassistant/gui/main_window.py delete line 81 with "self.main_win.hide()"
- run tests with "./setup.py test"
- after doing gui tests (they should pass) an empty window shows up and pytest freezes. If you do not delete 
the line "self.main_win.hide()", the window won't show but pytest freezes anyway

I am really helpless with it. Moving the gui test to be last works, but it is rather a workaround and I 
cannot assume it will work everywhere. I could not manage to "close" or "destroy" the main window so that it 
wouldn't show up and break the tests.
I tried these, but none worked:

app.main_win.destroy()
app.main_win.emit('delete-event', None)
Gtk.main_quit()

Do you please have any idea how to solve this?




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]