Closed jacopoabramo closed 4 months ago
Just answered myself by checking the local unit tests and the answer seems yes. Closing.
Yep! As you found, it works. I'll also note the long standing #46 "todo"... but that hasn't been urgent for me since I too just use pytest-qt in most cases
Another test pattern for synchronous applications is to connect your signal to a Mock(), perform your action, and then use mock.assert_called...
Another test pattern for synchronous applications is to connect your signal to a Mock(), perform your action, and then use mock.assert_called...
Do you have an example I can look at?
yeah, that pattern is used all throughout the tests in this repo, for example:
(note, it really doesn't need to be MagicMock
there... a simple Mock()
would also work fine)
Ah so you're mixing both unittest and pytest together. Clever, I might pick up on that since in the end I'm also using mock objects to test my logic. Thanks!
yeah, one doesn't need to be using unittest as a test runner to take advantage of patch
and mock
. Those are just generally useful objects regardless of your test runner
For a project I'm working on, I'm using psygnal as signaling mechanism within my application. I would like to run unit tests on some internal parts of my project to ensure everything works properly. Is it possible to use pytest-qt together with psygnal to run unit tests and ensure that signals are correctly emitted?