question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API break suggestions for 4.0

See original GitHub issue

As mentioned in https://github.com/pytest-dev/pytest-qt/pull/302#issuecomment-629513007 I went through the docs/code and thought about possible API breaks which would make sense for 4.0. Here are a couple of ideas:

  • 1. One thing that always irked me a bit is that we have two naming conventions (add_widget vs. addWidget). Is it really a good idea to support both? At least in my project, it only lead to using both inconsistently over the years without noticing. Should we get rid of one of those? On the other hand, that’s probably a lot of churn for projects using pytest-qt, so I’m not sure if it’s worth it. Maybe as an alternative, we could make it possible to configure the desired API style in pytest.ini so that the other style would raise an exception (that could be done after 4.0)?
  • 2. Right now the user needs to decide between waitActive, waitExposed and waitForWindowShown (which might be a hurdle if using the same tests for two different backends). Should we have a wrapper which decides what to use instead?
  • 3. Shouldn’t waitForWindowShown have a timeout as well? (can be done after 4.0)
  • 4. Does anyone really use qtbot.stopForInteraction() instead of qtbot.stop()? A GitHub search reveals 60 results, vs. 122 results for .stop(), though I guess it’s mostly used interactively for debugging without being added to the code. Should we remove the long name?
  • 5. Should we raise the default timeout for waitSignal() to 5000, similar to QSignalSpy.wait() in Qt and the other default timeouts in pytest-qt?
  • 6. waitSignal and waitSignals can take None instead of a signal, in which case they just wait until the timeout occurred. But we already have qtbot.wait() for that, so is there a reason to support it?
  • 7. Can we get rid of the SignalTimeoutError compatibility alias for TimeoutError?
  • 8. The docs for pytestqt.logging.Record says that context is only available for Qt 5, that can probably be removed now (can be done after 4.0)
  • 9. (new, see below) Get rid of qt_wait_signal_raising
  • 10. (new, see below) Get rid of aliases in plugin.py

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
The-Compilercommented, Jun 2, 2021

All done! 🎉

1reaction
The-Compilercommented, Jun 1, 2021

So I had a quick look at the waitActive, waitExposed and waitForWindowShown situation, and here’s what I gathered:

Now with Qt 4 support dropped, in theory we could also drop waitForWindowShown entirely. However, it seems quite widely used:

So it seems to me like we accidentally kept something alive which was long obsoleted/deprecated, and due to the pytest-qt layer, users wouldn’t notice any deprecation warnings (or the removals in the Qt 5 wrappers) at all…

Another problem is that we document both waitActive and waitExposed as:

This function is only available in PyQt5, raising a RuntimeError if called from PySide2/6.

and indeed do so:

https://github.com/pytest-dev/pytest-qt/blob/5ea3a3d292dd30b721ef333d9372a221abbbd5a9/src/pytestqt/qtbot.py#L732-L733

but in fact at least the underlying Qt functions are available with both PySide2 and PySide6. Looking at #159, I think what we actually wanted to say there is that it’s not available with PyQt4 and PySide (i.e. on Qt 4), but at that time PyQt5 was the only supported Qt 5 wrapper. Somehow this stayed around until today, despite PySide2 and then later PyQt6 and PySide6 being added…

So I’m not sure how to proceed here. We definitely should support all wrappers with waitActive and waitExposed, but what do we do with waitForWindowShown given the widespread usage (and only option so far if using PySide2 or Qt 6)? Options I can think of:

  • Keep the wrapper but add a deprecation warning
  • As above, but fail hard if PYTEST_QT_API is set to PySide6/PyQt6 (because the upstream method is fully gone there)
  • Remove the wrapper and force people to adjust, given that this has been deprecated in Qt for 9 years and we’re doing a major release here

What do you think @nicoddemus?

Read more comments on GitHub >

github_iconTop Results From Across the Web

API break suggestions for 4.0 · Issue #306 · pytest-dev ...
1. One thing that always irked me a bit is that we have two naming conventions ( add_widget vs. · 2. Right now...
Read more >
c# - Breaking changes in .NET 4.0
So I wonder what are other changes and is it possible to find at least preliminary list of changes that will or may...
Read more >
Looker API 4.0 Generally Available
The generally available API 4.0 will have multiple breaking and additive changes and will promote multiple endpoints from Beta to Stable.
Read more >
API upgrades | Stripe Documentation
To safely upgrade your webhooks, Stripe recommends that you: Check for breaking changes to see which objects will be structured differently.
Read more >
Runtime Changes for Migration from .NET Framework 4.0 ...
These same APIs break some ApiVerifier scenarios when HighVersionLie is enabled. Suggestion. This bug can be avoided by upgrading to .NET ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found