Skip to content

TST: properly fence-post qt{4,5} backend tests - #5195

Merged
jenshnielsen merged 5 commits into
matplotlib:v1.5.xfrom
tacaswell:fix_backend_qt_test
Oct 7, 2015
Merged

jenshnielsen merged 5 commits into
matplotlib:v1.5.xfrom
tacaswell:fix_backend_qt_test

Conversation

@tacaswell

Copy link
Copy Markdown
Member

This issue is that the new 'default' qt version is 5 if it is
available. In the tests the backend is Agg so we are hitting the
fall through behavior. If both pyqt4 and pyqt5 are installed, then
QtCore will be from PyQt5, but the backend_qt4Agg code assumes that it
is seeing the PyQt4 version of the classes. This results in error on
__init__ due to the change between PyQt4 and PyQt5.

Added test_backend_qt5.py to white listed tests.

closes #5194

This issue is that the new 'default' qt version is 5 if it is
available.  In the tests the backend is Agg so we are hitting the
fall through behavior.  If both pyqt4 and pyqt5 are installed, then
`QtCore` will be from PyQt5, but the backend_qt4Agg code assumes that it
is seeing the PyQt4 version of the classes.  This results in error on
`__init__` due to the change between PyQt4 and PyQt5.

Added test_backend_qt5.py to white listed tests.

closes matplotlib#5194
@tacaswell tacaswell added this to the next point release (1.5.0) milestone Oct 6, 2015
@tacaswell

Copy link
Copy Markdown
Member Author

This addresses one of the problems, but now the qt4 test segfaults on exit with pyqt4 and durring the tests with pyside

@tacaswell

Copy link
Copy Markdown
Member Author

and it seems that pyside is just flat out broken now...hurray

@tacaswell tacaswell mentioned this pull request Oct 6, 2015
Do not let a `super` be called or the the c++ base-classes will be
initialized twice which causes havoc.

 - pyside failed on figure creation
 - pyqt4 may segfault on exit

closes matplotlib#5196
If:

 1. backend is not Qt{4,5}Agg
 2. PyQt4 and PySide are installed, PyQt5 is not
 3. backend.qt4 == 'PySide'

The fall through will start trying to import PyQt5 (so sip will be
imported as it is installed for PyQt4).  It will then fall back to Qt4
using the binding specified in the rcparam ('PySide') which will then
miss the qt4 import conditionals which means QtCore is never imported
which means we get name errors from the pyqt / pyside patch up code.

This catches those exceptions and gives pyside a chance to be imported.
@tacaswell

Copy link
Copy Markdown
Member Author

@sandrotosi This should fix this round of errors 😸

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this should be six.unichr so it doesn't fail if the default encoding is something that can't handle Unicode codepoint 225...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As far as i know pyqt5 is py3 so I thought this was fine.

On Tue, Oct 6, 2015, 08:37 Michael Droettboom notifications@github.com
wrote:

In lib/matplotlib/tests/test_backend_qt5.py
#5195 (comment):

@@ -133,7 +135,7 @@ def test_control_alt():
def test_modifier_order():
assert_correct_key(QtCore.Qt.Key_Aacute,
(ControlModifier | AltModifier | SuperModifier),

  •                   'ctrl+alt+super+' + unichr(225))
    
  •                   'ctrl+alt+super+' + chr(225))
    

Maybe this should be six.unichr so it doesn't fail if the default encoding
is something that can't handle Unicode codepoint 225...

—
Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/5195/files#r41257615.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pyqt5 also runs on python 2.7

@sandrotosi

Copy link
Copy Markdown
Contributor

cool, thanks @tacaswell ! I'm going to test those patches right now

@tacaswell

Copy link
Copy Markdown
Member Author

One gotcha of this is that we can not test both pyqt4, pyside, and qt5 in the same process as their imports fight with each other.

@sandrotosi

Copy link
Copy Markdown
Contributor

I can confim those commits fix the tests errors!

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.

4 participants