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

Skip to content

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

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 5 commits into from
Oct 7, 2015

Conversation

tacaswell
Copy link
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
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
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
Member Author

@sandrotosi This should fix this round of errors 😸

@@ -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))
Copy link
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
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 [email protected]
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
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
Contributor

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

@tacaswell
Copy link
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
Contributor

I can confim those commits fix the tests errors!

jenshnielsen added a commit that referenced this pull request Oct 7, 2015
TST: properly fence-post qt{4,5} backend tests
@jenshnielsen jenshnielsen merged commit c4b9f4e into matplotlib:v1.5.x Oct 7, 2015
@tacaswell tacaswell deleted the fix_backend_qt_test branch October 29, 2015 16:08
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