application changes persist through tests, qtbot.mouseClick() not working on sample test application
See original GitHub issueApologies in advance for reporting two issues at the same time, but I figured it would be messier to have two tracked issues with mostly identical contents.
Application changes persist through tests
This is the main issue that I am encountering on the application I am developing. The application automatically stores UI changes through QSettings, for this reason I have made a fixture with autouse=True
that unsets $HOME so that no configuration is saved. I have been able to confirm through strace
that no configuration is saved to disk by QSettings this way.
Furthermore I have made a fixture with a function scope that instances the window, yields and then closes it. Regardless, when qtbot clicks something, the effect of that click is brought to the subsequent tests. A test toggles an option, which causes another test that expects the application to be in its default state to fail.
I have created a PoC file with a simple application containing just a checkbox that saves state through QSettings, and two tests that click the same checkbox: test.py.txt
qtbot.mouseClick() not working on sample test application
While it works on the real application I am developing, qtbot seems to not work in the PoC that I made for this bug report even though I cannot see any substantial difference in the two codes.
The sample application has a handler linked to the checkbox that logs on a file whenever it’s triggered. This never happens when qtbot sends the click, but when I do it in the stopForInteraction()
segment it works as it should.
Chances are I am overlooking something stupid, but despite my best efforts I cannot see anything that would warrant the malfunction.
Even though I cannot get qtbot to work properly, I could still reproduce the first issue - when I click the checkbox during the stopForInteraction() of the first test, the checkbox state is preserved on the second stopForInteraction() part.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@nicoddemus, @xstasi, & @The-Compiler, please see the answers to my StackOverflow questions as they may help you and future users with the same problem(s):
pytest-qt
FunctionmouseMove()
Not Workingpytestqt.mouseMove
to menubar menu widget moves to wrong placeThanks for the links!