Skip to content

waitSignal and waitSignals() evaluate signal parameters #141

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

Merged
merged 3 commits into from
Jul 28, 2016
Merged

waitSignal and waitSignals() evaluate signal parameters #141

merged 3 commits into from
Jul 28, 2016

Conversation

MShekow
Copy link

@MShekow MShekow commented Jul 14, 2016

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

… 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
@coveralls
Copy link

coveralls commented Jul 14, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling b8507e3 on MShekow:master into f4a6bbb on pytest-dev:master.

@@ -234,7 +234,7 @@ def stopForInteraction(self):

stop = stopForInteraction

def waitSignal(self, signal=None, timeout=1000, raising=None):
def waitSignal(self, signal=None, timeout=1000, callback=None, raising=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this parameter should appear at the end, so code doing waitSignal(signal, 1000, True) won't break.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I feel callback is to generic... perhaps check_params_callback would convey the intent a little better?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind this rename.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_params_cb maybe? I think _cb is a common suffix, and check_params_callback seems so long 😉

@nicoddemus
Copy link
Member

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)
@coveralls
Copy link

coveralls commented Jul 14, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling a8cee4c on MShekow:master into f4a6bbb on pytest-dev:master.

@The-Compiler
Copy link
Member

hmm, no idea why the windows builds are broken...

if signal is not None:
blocker.connect(signal)
return blocker

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: No spaces around default values

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think I'd rename force_order to order, and the parameters should be at the end as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MShekow
Copy link
Author

MShekow commented Jul 14, 2016

As I've never done PRs, I'd like to know whether the general procedure is this one?:
You suggest changes to the code, I add them to my fork, and once you're satisfied, you merge the PR?

@The-Compiler
Copy link
Member

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.

@The-Compiler
Copy link
Member

FWIW I get the same AppVeyor issue for qutebrowser as well. I'll investigate tomorrow.

:param int timeout:
How many milliseconds to wait before resuming control flow.
:param str force_order:
"none": no order is enforced
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format those as a list, like in here. The results are worth it IMO.

@nicoddemus
Copy link
Member

@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.

@The-Compiler
Copy link
Member

@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..)

@nicoddemus
Copy link
Member

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.

@The-Compiler
Copy link
Member

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)

@nicoddemus
Copy link
Member

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 pytestbot.

@nicoddemus
Copy link
Member

It broke only the docs environment now. 😁

@MShekow
Copy link
Author

MShekow commented Jul 18, 2016

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:

  1. Argument-capturing for SignalBlocker (all_args) and MultiSignalBlocker (recording the signals and their args in order)
  2. More descriptive error message in SignalTimeoutError
    The 2 points together are a couple of hours of work, given that I'd need to write tests for these new features, too.

* 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
@coveralls
Copy link

coveralls commented Jul 18, 2016

Coverage Status

Coverage decreased (-0.1%) to 99.888% when pulling 2e21419 on MShekow:master into f4a6bbb on pytest-dev:master.

@nicoddemus
Copy link
Member

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 2.1. @The-Compiler what do you think?

@nicoddemus
Copy link
Member

@MShekow if you could go ahead and fix the cosmetic issues it would be great.

@The-Compiler
Copy link
Member

The-Compiler commented Jul 26, 2016

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 order="strict" the default though, as we're already breaking stuff with v2.0 anyways.

@nicoddemus
Copy link
Member

I will try to merge this tonight together with #130 and make the 2.0 release then.

@The-Compiler
Copy link
Member

@nicoddemus What do you think about my comment regarding the default ordering above?

@nicoddemus
Copy link
Member

I'm wondering if we should make order="strict" the default though, as we're already breaking stuff with v2.0 anyways.

Oh forgot to comment: I agree with using strict as default, but this is a new feature so we won't be breaking anything, right?

@The-Compiler
Copy link
Member

Nope - MultiSignalBlocker already existed before and didn't care in which order the signals were emitted. If we turn on the order checking by default now, that is a breaking change.

@nicoddemus
Copy link
Member

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.

@The-Compiler
Copy link
Member

The-Compiler commented Jul 28, 2016

Hmm, true. I reviewed my usage of waitSignals and it has many instances where the order is fixed but I don't actually care (e.g. a Question object in a prompt emitting answered, completed and answered_no), and some instances where I care (e.g. [reply.metaDataChanged, reply.readyRead, reply.finished]). Let's keep it.

edit: So what you said above, essentially 😆

@nicoddemus nicoddemus merged commit bad3a3b into pytest-dev:master Jul 28, 2016
@nicoddemus
Copy link
Member

Merged. Thanks @MShekow again for the PR!

nicoddemus added a commit that referenced this pull request Jul 28, 2016
@The-Compiler
Copy link
Member

So... I'm a bit late, but I just realised check_params_cb and order aren't mentioned in the signal docs at all, and order isn't even in the changelog.

@nicoddemus
Copy link
Member

Thanks, completely missed that. Good thing the documentation is live, so it can be fixed on master. Created #147 for it. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants