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

Skip to content

Add basic testing of interactive backends. #8660

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 1 commit into from
May 26, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 23, 2017

Just checking that we can open a window and trigger an exit upon draw_event. The idea is to prevent issues such as #8563 (except that it wouldn't have prevented that specific issue as PyQt4 is not pip-installable... I haven't tried apt-installing GUI toolkits as that would only work for some specific python versions anyways).

.travis.yml Outdated
# GUI toolkits are pip-installable only for some versions of Python.
# Moreover, wxPython is only pip-installable as a pre-release for now.
pip install pyqt5 || true
pip install --pre wxpython || true
Copy link
Member

Choose a reason for hiding this comment

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

But wxpython is in the list above?

Copy link
Contributor Author

@anntzer anntzer May 23, 2017

Choose a reason for hiding this comment

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

typo, removed (from the first list)

if [[ $TRAVIS_OS_NAME != 'osx' ]]; then
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
fi
Copy link
Member

Choose a reason for hiding this comment

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

Travis docs suggest a sleep here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Except that we're going to build matplotlib before running any tests, so xvfb should have more than enough time to start :-)

Copy link
Member

Choose a reason for hiding this comment

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

Didn't building already happen in install?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even then, just test collection should give us enough time.

@QuLogic
Copy link
Member

QuLogic commented May 23, 2017

It looks like wxPython is building from source and failing due to missing GStreamer.

I was hoping we could use something like pytest-boxed for the individual backend tests, but that plugin seems all or nothing and doesn't appear to have much development.

@anntzer
Copy link
Contributor Author

anntzer commented May 23, 2017

good catch, let's see whether wxpython's snapshot wheels work...

@anntzer
Copy link
Contributor Author

anntzer commented May 24, 2017

I dropped wxpython, whose wheels appear not to work on 12.04 (due to a libpng version mismatch), so we're only left with tk and qt5agg for now (but that's already better than nothing IMO).
We should be able to add wx back in once the travis build env switches to 14.04 as wx has wheels for that version (https://wxpython.org/Phoenix/snapshot-builds/linux/gtk3/).

edit: yay to improved coverage (https://codecov.io/gh/matplotlib/matplotlib/pull/8660/changes)

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

👍

@dstansby
Copy link
Member

I think appveyor is generally broken with unrelated TeX issues.

("Tkinter", "tkagg"),
("tkinter", "tkagg")]:
try:
__import__(module_name)
Copy link
Member

Choose a reason for hiding this comment

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

https://docs.python.org/3.6/library/functions.html#__import__ <- This suggests to use import lib instead, is there a reason not to here? I have a vague sense of this playing badly with pypi.

Importing multiple GUI frameworks into one process can still cause problems because some of them install something onto PyOS_InputHook, but given that within the context of the test suite we should never land in the repl I think this is ok.

https://docs.python.org/3.6/library/importlib.html#importlib.util.find_spec (for py3) and https://docs.python.org/2.7/library/imp.html#imp.find_module (for py2) might be a better option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would have used importlib.import_module if we were Py3-only, but to be honest I had lost track of what Py2 supports. Anyways, I'll fix it.
I think GUI frameworks "should" only install an inputhook when their mainloop is started, which is not the case here. To be honest I'd rather not have to add version-specific code unless strictly necessary.

@tacaswell
Copy link
Member

Nominally 👍 , would like a second opinion on if my concerns about not importing multiple GUIs is worth digging into any more.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone May 25, 2017
environ["MPLBACKEND"] = backend
proc = Popen([sys.executable, "-c", _test_script], env=environ)
# Empirically, 1s is not enough on Travis.
assert proc.wait(timeout=5) == 0
Copy link
Member

Choose a reason for hiding this comment

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

Appveyor on python 2.7 doesn't like timeout=5 for some reason - https://ci.appveyor.com/project/matplotlib/matplotlib/build/1.0.1635/job/d70betvulec3rx10#L1592

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because windows + py2 doesn't use subprocess32. I'm a bit surprised that the DISPLAY env variable is set on windows though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bah, let's ignore py2. that'll also let me handle @tacaswell's concern re: importing.

Copy link
Member

Choose a reason for hiding this comment

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

a py2 issue was the source of the instigating bug 😈

I am 👍 on this being a py3 only test though.

@anntzer
Copy link
Contributor Author

anntzer commented May 25, 2017

i think the appveyor failure is spurious...

@tacaswell tacaswell merged commit 718ac86 into matplotlib:master May 26, 2017
@anntzer anntzer deleted the xvfb-tests branch May 26, 2017 15:14
@QuLogic
Copy link
Member

QuLogic commented May 27, 2017

The only trouble with this now is that locally I see a random window flashing during testing.

@anntzer
Copy link
Contributor Author

anntzer commented May 29, 2017

Is that really a problem? I do want to trigger a draw through the gui event loop during the test.

@QuLogic
Copy link
Member

QuLogic commented May 29, 2017

Right, I know; it's just a minor irk.

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.

4 participants