Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: Defer loading Qt framework until test is run. #12163

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 2 commits into from
Sep 27, 2018

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Sep 19, 2018

PR Summary

If Qt4 and Qt5 are both available, then test_backend_qt4.py will force the loading of the Qt4 framework. If the user selected Qt5 tests only, they will not be able to run even though the Qt4 tests never ran either.

I'd really like it if we could consolidate these two files together, but I'm having a little trouble getting a local fixture (which would check for the right Qt and skip otherwise) to run before the global mpl_test_settings fixture (which would try to switch the Qt backends and possibly fail).

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

_, SuperModifier, SuperKey = MODIFIER_KEYS[SUPER]
_, ShiftModifier, ShiftKey = MODIFIER_KEYS[SHIFT]
@pytest.fixture
def qt_key(request):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these just take qt4_module as arg? (and so on for the following ones)

Copy link
Member Author

Choose a reason for hiding this comment

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

They can; I did not do that yet as I was trying to figure out if we can combine these two files somehow.

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

The general approach looks good, I guess you're going to do more work in later PRs?

@QuLogic
Copy link
Member Author

QuLogic commented Sep 19, 2018

Seems there is a slight problem with the order fixtures are run causing issues when neither Qt version is installed. I think I do have a workaround, though it's a bit annoying.

@tacaswell tacaswell added this to the v3.0.x milestone Sep 19, 2018
@QuLogic
Copy link
Member Author

QuLogic commented Sep 20, 2018

It's a bit annoying, but using pytest_generate_tests, we can ensure that fixtures are run in the right order. I've also figured out how to merge these two files, but I assume we don't want to backport that.

If Qt4 and Qt5 are both available, then `test_backend_qt4.py` will force
the loading of the Qt4 framework. If the user selected Qt5 tests only,
they will not be able to run even though the Qt4 tests never ran either.
If it's not run first, then the `mpl_test_settings` fixture will attempt
to switch backends before the skip is triggered.
@QuLogic
Copy link
Member Author

QuLogic commented Sep 24, 2018

Oops, turns out pytest_generate_tests doesn't work because newer versions don't allow you to modify the fixture list from it. The current method of redefining mpl_test_settings does work though and should be something that won't be broken accidentally according to upstream.

@tacaswell tacaswell merged commit 5229d4a into matplotlib:master Sep 27, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 27, 2018
@QuLogic QuLogic deleted the defer-qt-loading branch September 27, 2018 03:29
QuLogic added a commit that referenced this pull request Sep 27, 2018
…163-on-v3.0.x

Backport PR #12163 on branch v3.0.x (TST: Defer loading Qt framework until test is run.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants