diff --git a/qtpy/QtLocation.py b/qtpy/QtLocation.py index 1f7132dc..cf6de337 100644 --- a/qtpy/QtLocation.py +++ b/qtpy/QtLocation.py @@ -8,18 +8,27 @@ """Provides QtLocation classes and functions.""" from . import ( + parse, PYQT5, PYQT6, PYSIDE2, PYSIDE6, + PYQT_VERSION, + PYSIDE_VERSION, QtBindingMissingModuleError, ) if PYQT5: from PyQt5.QtLocation import * elif PYQT6: - raise QtBindingMissingModuleError(name='QtLocation') + if parse(PYQT_VERSION) >= parse('6.5'): + from PyQt6.QtLocation import * + else: + raise QtBindingMissingModuleError(name='QtLocation') elif PYSIDE2: from PySide2.QtLocation import * elif PYSIDE6: - raise QtBindingMissingModuleError(name='QtLocation') + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtLocation import * + else: + raise QtBindingMissingModuleError(name='QtLocation') diff --git a/qtpy/QtSerialBus.py b/qtpy/QtSerialBus.py new file mode 100644 index 00000000..e46774bf --- /dev/null +++ b/qtpy/QtSerialBus.py @@ -0,0 +1,30 @@ +# ----------------------------------------------------------------------------- +# Copyright © 2009- The Spyder Development Team +# +# Licensed under the terms of the MIT License +# (see LICENSE.txt for details) +# ----------------------------------------------------------------------------- + +"""Provides QtSerialBus classes and functions.""" + +from . import ( + parse, + PYQT5, + PYQT6, + PYSIDE2, + PYSIDE6, + PYSIDE_VERSION, + QtBindingMissingModuleError, +) + +if PYQT5: + from PyQt5.QtSerialBus import * +elif PYQT6: + from PyQt6.QtSerialBus import * +elif PYSIDE2: + from PySide2.QtSerialBus import * +elif PYSIDE6: + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtSerialBus import * + else: + raise QtBindingMissingModuleError(name='QtSerialBus') diff --git a/qtpy/QtTextToSpeech.py b/qtpy/QtTextToSpeech.py index cd978328..669941c2 100644 --- a/qtpy/QtTextToSpeech.py +++ b/qtpy/QtTextToSpeech.py @@ -7,11 +7,13 @@ """Provides QtTextToSpeech classes and functions.""" -from . import ( +from packaging.version import parse +from qtpy import ( PYQT5, PYQT6, PYSIDE2, PYSIDE6, + PYSIDE_VERSION, QtBindingMissingModuleError, ) @@ -22,4 +24,7 @@ elif PYSIDE2: from PySide2.QtTextToSpeech import * elif PYSIDE6: - raise QtBindingMissingModuleError(name='QtTextToSpeech') + if parse(PYSIDE_VERSION) >= parse('6.5'): + from PySide6.QtTextToSpeech import * + else: + raise QtBindingMissingModuleError(name='QtTextToSpeech') diff --git a/qtpy/tests/test_qtserialbus.py b/qtpy/tests/test_qtserialbus.py new file mode 100644 index 00000000..3440df94 --- /dev/null +++ b/qtpy/tests/test_qtserialbus.py @@ -0,0 +1,28 @@ +"""Test QtSerialBus.""" + +import pytest +from qtpy import ( + parse, + PYSIDE6, + PYSIDE_VERSION, + QtBindingMissingModuleError, +) + + +@pytest.mark.skipif(not PYSIDE6 or parse(PYSIDE_VERSION) >= parse('6.5'), reason='.') +def test_qtserialbus_pyside6_below_6_5(): + with pytest.raises(QtBindingMissingModuleError) as excinfo: + from qtpy import QtSerialBus + + +@pytest.mark.skipif(not PYSIDE6 or parse(PYSIDE_VERSION) < parse('6.5'), reason='.') +def test_qtserialbus_pyside6_above_6_5(): + """Test the qtpy.QtSerialBus namespace""" + from qtpy import QtSerialBus + + assert QtSerialBus.QCanBus is not None + assert QtSerialBus.QCanBusDevice is not None + assert QtSerialBus.QCanBusDeviceInfo is not None + assert QtSerialBus.QModbusClient is not None + assert QtSerialBus.QModbusServer is not None + assert QtSerialBus.QModbusDevice is not None