@pytest.fixture
def qt_module(request):
    (backend,) = request.node.get_closest_marker('backend').args
    if (backend == 'Qt4Agg'):
        try:
            import PyQt4
        except (ImportError, RuntimeError):
            try:
                import PySide
            except ImportError:
                pytest.skip('Failed to import a Qt4 binding.')
    elif (backend == 'Qt5Agg'):
        try:
            import PyQt5
        except (ImportError, RuntimeError):
            try:
                import PySide2
            except ImportError:
                pytest.skip('Failed to import a Qt5 binding.')
    else:
        raise ValueError(('Backend marker has unknown value: ' + backend))
    qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
    QtCore = qt_compat.QtCore
    if (backend == 'Qt4Agg'):
        try:
            py_qt_ver = int(QtCore.PYQT_VERSION_STR.split('.')[0])
        except AttributeError:
            py_qt_ver = QtCore.__version_info__[0]
        if (py_qt_ver != 4):
            pytest.skip(reason='Qt4 is not available')
        from matplotlib.backends.backend_qt4 import MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT
    elif (backend == 'Qt5Agg'):
        from matplotlib.backends.backend_qt5 import MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT
    mods = {}
    keys = {}
    for (name, index) in zip(['Alt', 'Control', 'Shift', 'Super'], [ALT, CTRL, SHIFT, SUPER]):
        (_, mod, key) = MODIFIER_KEYS[index]
        mods[(name + 'Modifier')] = mod
        keys[(name + 'Key')] = key
    return (QtCore, mods, keys)
@pytest.fixture
def qt_module(request):
    (backend,) = request.node.get_closest_marker('backend').args
    if (backend == 'Qt4Agg'):
        try:
            import PyQt4
        except (ImportError, RuntimeError):
            try:
                import PySide
            except ImportError:
                pytest.skip('Failed to import a Qt4 binding.')
    elif (backend == 'Qt5Agg'):
        try:
            import PyQt5
        except (ImportError, RuntimeError):
            try:
                import PySide2
            except ImportError:
                pytest.skip('Failed to import a Qt5 binding.')
    else:
        raise ValueError(('Backend marker has unknown value: ' + backend))
    qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
    QtCore = qt_compat.QtCore
    if (backend == 'Qt4Agg'):
        try:
            py_qt_ver = int(QtCore.PYQT_VERSION_STR.split('.')[0])
        except AttributeError:
            py_qt_ver = QtCore.__version_info__[0]
        if (py_qt_ver != 4):
            pytest.skip(reason='Qt4 is not available')
        from matplotlib.backends.backend_qt4 import MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT
    elif (backend == 'Qt5Agg'):
        from matplotlib.backends.backend_qt5 import MODIFIER_KEYS, SUPER, ALT, CTRL, SHIFT
    mods = {}
    keys = {}
    for (name, index) in zip(['Alt', 'Control', 'Shift', 'Super'], [ALT, CTRL, SHIFT, SUPER]):
        (_, mod, key) = MODIFIER_KEYS[index]
        mods[(name + 'Modifier')] = mod
        keys[(name + 'Key')] = key
    return (QtCore, mods, keys)