-
-
Notifications
You must be signed in to change notification settings - Fork 69
Support for capturing signals and args and improved SignalTimeoutError messages #153
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
Conversation
… (into blocker.all_args) and improved the message of SignalTimeoutError to include the name of the signal, non-matching signal parameters and name of the callback. Next step is to include similar functionality for MultiSignalBlocker.
…ee all_signals_and_args). Cleaned up large parts of the code of MultiSignalBlocker for better readability. Updated documentation. Added tests. #151
:param Signal signal: | ||
A signal to wait for. Set to ``None`` to just use timeout. | ||
A signal to wait for, or a tuple (signal, signal_name_as_str) to improve the error message that is part |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tuple should be monospaced as well for consistency
Thanks for your great work on this, looking forward to it! I added some style comments, and plan to take another closer look when I feel more awake 😆 Some other things to note:
|
Hi. I'm having trouble fixing the bugs. The most problematic issue is unicode strings. Python 2 and 3 seem to work very different (I don't personally care for legacy software, so I never use Python 2). Python 2 breaks my tests because it converts |
Why don't you want the |
Well, I didn't want the u there due to the tests. I'll follow your suggestion and adapt the tests instead. |
…nts (that we emit in test code as normal strings) are converted to "PyQt4.QtCore.QString(u'<stringcontent>')" by repr(), while as for all other Python 2 builds, this is just "u'<stringcontent>'".
So, I've fixed all those things you mentioned and got the tests working again.
|
Getting emitted signals and arguments | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. versionadded:: 2.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guess for the next version actually correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! 😁
I've done the necessary changes. I don't know how to further increase the coverage, tbh. Please note that coveralls seems to be buggy and the comments aren't always accurate. The actual reduction is by 0.09%. I understand I could get it back to 0% if I had the overriding |
if self._timer is not None: | ||
_silent_disconnect(self._timer.timeout, self._quit_loop_by_timeout) | ||
self._timer.stop() | ||
self._timer = None | ||
|
||
def get_timeout_error_message(self): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this must be overridden in subclasses, you should do raise NotImplementedError
here (docs) - that should also mean no coverage is required for it, and if coverage.py doesn't do so automatically, we can tell it to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it in the code, but coveralls still complains about that line not being covered. So, should I use a pragma? I don't see any configuration files in place yet.
For this case specifically I would say it is fair to add a |
Getting all arguments of non-matching arguments | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. versionadded:: 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 2.1?
Hey @MShekow, excellent documentation on the tests and code! Other than adding the comment to skip the missing coverage, my suggestions are just that, suggestions, so feel free to not implement them if you don't really have the time as I'm guessing you have spent quite a few hours on this already. All your work here is much appreciated! |
signal_name = signal_tuple[1] | ||
if not isinstance(signal_name, str) or not signal_name: | ||
raise TypeError("Invalid type for user-provided signal name, " | ||
"expected str but got {}".format(type(signal_name))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone accidentally passed an empty string, they'd get "Invalid type for user-provided signal name, expected str but got str", which might be quite confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll fix this, i.e. split it into two if
s (each one without any or
).
3 similar comments
Hey @MShekow, Really sorry about the delay on this. Just now I found the time to review it and it looks great! Your entire PR is very well written and your test descriptions are really helpful! 👍 Long overdue, I'm merging this! I plan to have 2.1 out soon real soon. 😁 Also, thanks @The-Compiler for the through review as well. 😉 |
My pleasure! Thanks for merging :) |
waitSignal()
: added support for capturing arguments when callback was not satisfied (intoblocker.all_args
) and improved the message ofSignalTimeoutError
to include the name of the signal, non-matching signal parameters and name of the callback.waitSignals()
: Added capturing signals and their arguments (seeall_signals_and_args
). Cleaned up large parts of the code ofMultiSignalBlocker
for better readability. Improved the message ofSignalTimeoutError
. Updated documentation. Added tests. See #151