Skip to content

Add pytest-xvfb to dev environment #23725

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

Closed
wants to merge 1 commit into from

Conversation

oscargus
Copy link
Member

PR Summary

In #23231 pytest-xvfb was added as a test dependency, but I missed the development environment. This PR adds it to that.

pytest-xvfb will run the tests using a headless x-server, xvfb, if available, so on Linux machines (maybe OSX?), there will be no windows popping up during tests.

No strictly required for 3.6.0, but I think it would make sense to add it there as well.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus added this to the v3.6.0 milestone Aug 24, 2022
@@ -56,5 +56,6 @@ dependencies:
- pytest-rerunfailures
- pytest-timeout
- pytest-xdist
- pytest-xvfb
Copy link
Member

Choose a reason for hiding this comment

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

What does this do on mac/windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing. No harm in having it installed (except for storage space). And if xvfb on Linux is not installed, it won't complain either.

@greglucas
Copy link
Contributor

Do I have to disable my current X display now? That seems like asking a bit much, but maybe I'm missing a configuration somewhere...

pip install pytest-xvfb
pytest lib/matplotlib/tests/test_backend_qt.py

produces this error

INTERNALERROR>     raise XStartError(
INTERNALERROR> pyvirtualdisplay.abstractdisplay.XStartError: No success after 10 retries. Last stderr: b"_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.\n_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 2\n_XSERVTransMakeAllCOTSServerListeners: failed to create listener for local\n(EE) \nFatal server error:\n(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE) \n"

then I uninstall and the test suite runs again with no error.

@oscargus
Copy link
Member Author

Do I have to disable my current X display now?

I've only used it out of the box and as I understand, the whole point is that it will detect if xvfb is available and if so start it, if required. If not, it should just go on as normal. No problems on CentOS (without xvfb installed) nor Arch (with xvfb installed).

It may be that this is an OSX issue? It seems like pyVirtualDisplay is tested on both 10.15 and 11, but installs xquartz. We are using it on the CI for OSX as well, without installing xquartz.

@oscargus
Copy link
Member Author

https://stackoverflow.com/questions/65890804/xstarterror-in-pyvirtualdisplay

(But not so interesting answer...)

@greglucas
Copy link
Contributor

Interesting, it may have been something wrong with an older version of xquartz that I had installed locally. I updated that and now I don't get any errors, but I also don't get the windows being hidden... They still pop up in front of my active window and take priority. This could be because I only have the command xvfb and not xvfb-run...
My take on it is that this is a "nice to have" feature for Linux, but not required and could cause issues for new contributors trying to run the tests (myself included!) if their Xwindows aren't set up properly. I think adding this package as a suggestion to the installation docs might make sense instead of adding it to the environment file? https://matplotlib.org/stable/devel/dependencies.html#optional-dependencies

@oscargus
Copy link
Member Author

might make sense instead of adding it to the environment file?

It is there: https://matplotlib.org/devdocs/devel/dependencies.html#dependencies-for-testing-matplotlib

The origin of this PR is that all those are in the environment except for pytest-xvfb, e.g. pytest-xdist. But, indeed, if it causes problems on some machines it is not a good idea to add it.

@oscargus
Copy link
Member Author

(I realize that xarray is also missing, but since I did the PR adding xarray as a test dependency I am not surprised I missed to add it to environment as well...)

@timhoffm
Copy link
Member

Unfortunately, selectors are not supported in environment.yml conda/conda#8089

@oscargus
Copy link
Member Author

There is the pip hack: install pytest-xvfb using a pip section in case of Linux. Should I change to that or just close this PR?

@timhoffm
Copy link
Member

timhoffm commented Sep 7, 2022

I think pip (with a comment) is viable. If that's too messy, simply add the condo package but commented out, plus a hint that Linux/win users could activate it.

@QuLogic QuLogic modified the milestones: v3.6.0, v3.6.1 Sep 14, 2022
@QuLogic QuLogic modified the milestones: v3.6.1, v3.6.2 Oct 6, 2022
@tacaswell
Copy link
Member

I'm confused where this PR is. @timhoffm has approved, but the last comment seems to be asking for a change?

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

This seems to be causing problems on OSX, so should not be added unconditionally. Options are

a) Don't bother with pytest-xvfb here and close the PR
b) Put this in, but commented, plus a note that users on linux/win could activate it if they want
c) Put a pip install here, which supports selectors

I think b) is easiest and put in a suggestion for it.

@@ -56,5 +56,6 @@ dependencies:
- pytest-rerunfailures
- pytest-timeout
- pytest-xdist
- pytest-xvfb
Copy link
Member

Choose a reason for hiding this comment

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

Probably this is the easiest way forward

Suggested change
- pytest-xvfb
# - pytest-xvfb # can be included on linux/win to suppress windows popping up during the test

@QuLogic QuLogic modified the milestones: v3.6.2, v3.6.3 Oct 27, 2022
@oscargus oscargus removed this from the v3.6.3 milestone Dec 15, 2022
@oscargus
Copy link
Member Author

I close this. It is maybe a bit inconsistent to not have it in environment, but no harm in skipping it and as it apparently breaks on some Mac installs that seems like the best way.

@oscargus oscargus closed this Dec 15, 2022
@oscargus oscargus deleted the environmentpytestxvfb branch December 15, 2022 21:27
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.

5 participants