-
-
Notifications
You must be signed in to change notification settings - Fork 69
Improve waitSignal/waitSignals TimeoutError messages and catch arguments #151
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
Comments
I've had various issues with segfaults in the past when using For that reason, I'd really like to avoid using it (or doing other fun magic) in pytest-qt, even if that means worse error messages... |
All I can say is that it's hardcoded in the PyQt source: // Create a new signal instance.
qpycore_pyqtSignal *qpycore_pyqtSignal_New(const char *signature, bool *fatal)
{
// Assume any error is fatal.
if (fatal)
*fatal = true;
Chimera::Signature *parsed_signature = Chimera::parse(signature,
"a signal argument");
// [...]
parsed_signature->signature.prepend('2'); |
OK, so then, for
I like the combination of 2+3 best, where a hint is printed (?) by pytest-qt if the user uses PySide signals without providing the signals' names. The hint could be something like "to get better error messages in TimeoutError, consider providing signal names in the signal parameter". |
So with 3), you'd check if the user supplied a list of signals or a list of iterables/tuples, and then adjust accordingly? That could work out nicely.
For PySide, maybe once PySide2 is actually something usable, we could do a feature request for something similar upstream. As for printing, I guess this information should be part of the |
Alright. I started working on that feature. See https://github.com/MShekow/pytest-qt/commit/3f1a8a3388c87f0d733b6bf2747b60a952b377c2 |
Fixed by #153 |
Hi. I've started thinking about implementing these 2 features (as they are closely related). Originally @nicoddemus suggested that
SignalBlocker
could show the following message:I investigated a bit and it seems that it's not possible to get the actual name of the signal (here:
text_received
) withinSignalBlocker
. The reason is that Signal objects don't have a__name__
attribute. PyQt4/5 signals have an internalsignal
field which contains the name of the signal itself, prefixed with a'2'
(don't ask me why, I'll ask in the pyqt mailing list), whereas PySide signals have no attributes at all, theirstr()
representation is just something like<PySide.QtCore.SignalInstance object at 0x05D82880>
.I'm not sure how to continue now. For
SignalBlocker
it's not much of an issue, as thewait()
call of the blocker expects just one signal anyway, and the code line number in the stack trace of a failed test will allow the test engineer to figure out which signal exactly failed.However, I'd also like to add this feature to
MultiSignalBlocker
. Here it would be nice to have a human-readable form of all caught signals, including their parameters. From what we currently know, it wouldn't be possible to get the name of the emitted signals.After a bit more digging, I found that there could be a solution, if we can get
_AbstractSignalBlocker
to inherit fromQObject
. Because then we can get the signal by getting the signal's sender and iterating over its attributes, as follows:Is there a way to have
_AbstractSignalBlocker
inherit from the configuration-specific QObject implementation?Cheers!
Marius
The text was updated successfully, but these errors were encountered: