-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easing the use of QSettings #85
Comments
Hi! A simple way to accomplish this is by using a @pytest.fixture(scope='session', autouse=True)
def config_app_settings(qapp):
qapp.setOrganizationName('MyOrg')
qapp.setApplicationName('MyApp') This this code will execute exactly once per test session and will ensure your Hope this helps! 😄 |
Thank you very much! I was looking for something too complicated. I'm new to testing PyQt applications and have only done a little bit of django applications testing (without py.test). I suggest you mention this in the documentation. I think I believed I needed a modified plugin because the qapp fixture is not mentioned on readthedocs so I deduced (incorrectly) this was an internal detail of the plugin that I couldn't access. More generally I'd love to read much more documentation on testing Qt applications in python. It's much much harder to find than the corresponding documentation for django. Maybe the documentation of this plugin could include a larger tutorial testing a larger application having signal/slots, modal dialogs, model/views... Note that I may try to contribute such a tutorial in the future if I manage to understand enough... |
Glad that helps! 😄 I created a new issue for the docs at #86, thanks for the suggestion. If you don't have any more questions, could you then close the issue? |
Is it possible to easily tell the great qapp fixture of pytest-qt where it should look for settings?
Say my main code has
app = QApplication([])
followed byapp.setOrganizationName('MyOrg')
andapp.setApplicationName('MyApp')
. Maybe I'm doing this wrong but, since I don't want my tests to rely on (or alter) real world settings I would like my test to useapp.setOrganizationName('MyOrg')
andapp.setApplicationName('MyAppTest')
.Assuming the above is not completely wrong, I'd like the qtbot fixture of pytest-qt to use (through the qapp fixture) those settings. One solution that I see and doesn't seem to cost anything is to put in my conftest.py
and then modify the plugin in the qapp fixture to replace
by
Does it make sense? Should I do something completely different?
The text was updated successfully, but these errors were encountered: