waitSignal and waitSignals() evaluate signal parameters#141
waitSignal and waitSignals() evaluate signal parameters#141nicoddemus merged 3 commits intopytest-dev:masterfrom MShekow:master
Conversation
… makes it possible to test that emitted signals have specific parameters set. waitSignals() also has a force_order parameter that allows to configure 3 different levels of strictness regarding the order in which the signals are expected. #118
pytestqt/qtbot.py
Outdated
| stop = stopForInteraction | ||
|
|
||
| def waitSignal(self, signal=None, timeout=1000, raising=None): | ||
| def waitSignal(self, signal=None, timeout=1000, callback=None, raising=None): |
There was a problem hiding this comment.
I think this parameter should appear at the end, so code doing waitSignal(signal, 1000, True) won't break.
There was a problem hiding this comment.
Also I feel callback is to generic... perhaps check_params_callback would convey the intent a little better?
There was a problem hiding this comment.
check_params_cb maybe? I think _cb is a common suffix, and check_params_callback seems so long 😉
|
Hey @MShekow thanks a lot for the PR. I have to leave to work so I can't review it more carefully now, I will try to make a proper review during lunch, or at the end the day the latest. |
… makes it possible to test that emitted signals have specific parameters set. waitSignals() also has a force_order parameter that allows to configure 3 different levels of strictness regarding the order in which the signals are expected. #118 (this commit contains a bug fix for Python2.7 compatibility)
|
hmm, no idea why the windows builds are broken... |
pytestqt/qtbot.py
Outdated
| wait_signal = waitSignal # pep-8 alias | ||
|
|
||
| def waitSignals(self, signals=None, timeout=1000, raising=None): | ||
| def waitSignals(self, signals=None, timeout=1000, force_order = "none", callbacks = None, raising=None): |
There was a problem hiding this comment.
nitpick: No spaces around default values
There was a problem hiding this comment.
Also I think I'd rename force_order to order, and the parameters should be at the end as well.
There was a problem hiding this comment.
I'm OK with renaming the parameter to order and placing it at the end. Spaces around the default value of the parameter can be removed.
|
As I've never done PRs, I'd like to know whether the general procedure is this one?: |
|
Right - if you push new changes to your fork, the PR will update automatically. Then we review it again, you update it if needed, etc., until it gets merged. |
|
FWIW I get the same AppVeyor issue for qutebrowser as well. I'll investigate tomorrow. |
pytestqt/qtbot.py
Outdated
| :param int timeout: | ||
| How many milliseconds to wait before resuming control flow. | ||
| :param str force_order: | ||
| "none": no order is enforced |
|
@MShekow first let me say thank you for your extremely well written PR! I reviewed it partially, but I'm afraid is very late and I must get some sleep now. I will continue reviewing it tomorrow. |
|
@nicoddemus can you rerun AppVeyor now that #142 is in? (Also, it'd be nice if this plugin was under the pytestbot account on AppVeyor too..) |
|
Don't we have to merge with master to get your changes into this pr anyway? This would cause a new build to be triggered anyway. About the pytestbot user, I agree, will see how to do it. |
|
As far as I know, PRs on AppVeyor/Travis are always built against the latest master (which is also why they don't build when the PR is unmergeable) |
Oh really didn't notice that, but it makes sense! 😉 Just triggered a build, let's see how it goes. I'll look later how to move ownership of the project to |
|
It broke only the |
|
Hi. Are there any other remarks? I'll be going on vacation for the rest of July soon. Before that, I'll have time to fix all the rather "cosmetic" issues ;). There were 2 larger issues mentioned which I cannot complete before that:
|
* placed new parameters at the end * renamed "force_order" to "order" * renamed "callback" to "check_params_cb" and "callbacks" to "check_params_cbs" * improved various parts of the documentation * replaced assert with raising a ValueError
|
Hi @MShekow, sorry for the delay. If you are going on vacation soon, I would rather we merge it sooner and work on improving the error message in |
|
@MShekow if you could go ahead and fix the cosmetic issues it would be great. |
|
Sorry for the late answer - I was busy with Europython and a big mail-backlog after that, so I postponed everything which was a bit more work 😆 @nicoddemus I'm guessing @MShekow is in holidays by now - what cosmetic issues do you mean? I can see "docstring of pytestqt.qtbot.QtBot.waitSignal:36: WARNING: Inline emphasis start-string without end-string." on Appveyor, but it seems they fixed the other issues in 2e21419. The PR looks good otherwise (though I don't really understand the order handling and tests 100% yet 😆). I'm wondering if we should make |
|
I will try to merge this tonight together with #130 and make the 2.0 release then. |
|
@nicoddemus What do you think about my comment regarding the default ordering above? |
Oh forgot to comment: I agree with using |
|
Nope - |
|
Oh right, sorry. Hmm not sure TBH, it seems strict ordering only makes sense for signals coming from the same object. For multiple signals from different objects like the example code in the docs it doesn't make sense and is even error prone. |
|
Hmm, true. I reviewed my usage of edit: So what you said above, essentially 😆 |
|
Merged. Thanks @MShekow again for the PR! |
|
So... I'm a bit late, but I just realised |
|
Thanks, completely missed that. Good thing the documentation is live, so it can be fixed on |
waitSignal and waitSignals() have a callback/callbacks parameter that makes it possible to test that emitted signals have specific parameters set. waitSignals() also has a force_order parameter that allows to configure 3 different levels of strictness regarding the order in which the signals are expected. See #118