-
-
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
Catch exceptions in other Qt threads #11
Comments
Done in 1.1.1, if you have a change to try it out let me know what you think. Cheers! |
Wow, great implementation! One thing I would consider doing: move the new the context manager outside of the QtBot class, and define it as its own top-level definition. It doesn't seem to require a QtBot class instance for anything. That's just a style opinion I suppose. Thanks! EDIT: I didn't even notice you already made the new 1.1.1 release too. I'll start using this immediately to help test it out. |
It works great! As a sidenote, I wish using |
Excellent! Yes, I noticed that about Thanks again! |
Thanks for the suggestion about changing the context manager into a function. That allows me to test the code formatting code (see this commit if you want to check it out). Cheers! |
Nice! I like the formatting refactoring as well. It keeps the main fixture definition very clear. |
FWIW, it is probably more accurate to report these as "Exceptions caught in Qt event loop" rather than "Qt exceptions in virtual methods." This is because these exceptions can also be raised in a pyqt slot. |
…ead of virtual methods As suggested in: pytest-dev#11 (comment)
…ead of virtual methods As suggested in: pytest-dev#11 (comment)
@patrickkidd good point, thanks. Implemented it in #255. |
I recently switched to pytest-qt, and I love it so far. Before, I used my own pytest fixture to create a QApplication. I found a way to catch exceptions on all threads by overriding sys.excepthook in the fixture and checking for errors:
I created this so I can see when my table model methods fail. Without this, if an error happens in the
data()
orheader()
methods of a table model, like when a table view is being populated using the model, the test will not fail.I think something similar to this would be a nice feature of pytest-qt, but a better, less hacky implementation would probably be better.
The text was updated successfully, but these errors were encountered: