From 07f285b130303cf8af15f8ef0485cea0460ebbd8 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 11 Apr 2022 12:56:17 -0500 Subject: [PATCH 1/5] uic: Improve skip conditions for uic load* related tests --- qtpy/tests/test_uic.py | 52 ++++++++++++------------------------------ 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/qtpy/tests/test_uic.py b/qtpy/tests/test_uic.py index ecd50985..f873f1d2 100644 --- a/qtpy/tests/test_uic.py +++ b/qtpy/tests/test_uic.py @@ -12,7 +12,7 @@ pytest.importorskip("pyside2uic", reason="pyside2uic not installed") from qtpy import uic -from qtpy.uic import loadUi, loadUiType +from qtpy.tests.utils import not_using_conda QCOMBOBOX_SUBCLASS = """ @@ -42,30 +42,19 @@ def enabled_qcombobox_subclass(temp_dir_path): sys.path.pop(0) -def get_qapp(icon_path=None): - """ - Helper function to return a QApplication instance - """ - qapp = QtWidgets.QApplication.instance() - if qapp is None: - qapp = QtWidgets.QApplication(['']) - return qapp - - @pytest.mark.skipif( - os.environ.get('CI', None) is not None - and sys.platform.startswith('linux'), - reason="Segfaults on Linux CIs under all bindings (PYSIDE2/6 & PYQT5/6)") -def test_load_ui(): + sys.platform.startswith('linux') and not_using_conda(), + reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") +def test_load_ui(qtbot): """ Make sure that the patched loadUi function behaves as expected with a simple .ui file. """ - app = get_qapp() with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*mode.*") - ui = loadUi(os.path.join(os.path.dirname(__file__), 'test.ui')) + ui = uic.loadUi(os.path.join(os.path.dirname(__file__), 'test.ui')) + assert isinstance(ui.pushButton, QtWidgets.QPushButton) assert isinstance(ui.comboBox, QComboBox) @@ -74,19 +63,17 @@ def test_load_ui(): PYSIDE2 or PYSIDE6, reason="PySide2uic not consistantly installed across platforms/versions") @pytest.mark.skipif( - os.environ.get('CI', None) is not None - and sys.platform.startswith('linux'), - reason="Segfaults on Linux CIs under all bindings (PYSIDE2/6 & PYQT5/6)") -def test_load_ui_type(): + sys.platform.startswith('linux') and not_using_conda(), + reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") +def test_load_ui_type(qtbot): """ Make sure that the patched loadUiType function behaves as expected with a simple .ui file. """ - app = get_qapp() with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*mode.*") - ui_type, ui_base_type = loadUiType( + ui_type, ui_base_type = uic.loadUiType( os.path.join(os.path.dirname(__file__), 'test.ui')) assert ui_type.__name__ == 'Ui_Form' @@ -102,35 +89,26 @@ def __init__(self): @pytest.mark.skipif( - PYSIDE2 and sys.platform == "darwin" - and sys.version_info.major == 3 and sys.version_info.minor == 9 - and not_using_conda(), - reason="Fails on this specific platform, at least on our CIs") -@pytest.mark.skipif( - os.environ.get('CI', None) is not None - and sys.platform.startswith('linux'), - reason="Segfaults on Linux CIs under all bindings (PYSIDE2/6 & PYQT5/6)") -def test_load_ui_custom_auto(tmp_path): + sys.platform.startswith('linux') and not_using_conda(), + reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") +def test_load_ui_custom_auto(qtbot, tmp_path): """ Test that we can load a .ui file with custom widgets without having to explicitly specify a dictionary of custom widgets, even in the case of PySide. """ - - app = get_qapp() - with enabled_qcombobox_subclass(tmp_path): from qcombobox_subclass import _QComboBoxSubclass with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*mode.*") - ui = loadUi( + ui = uic.loadUi( os.path.join(os.path.dirname(__file__), 'test_custom.ui')) assert isinstance(ui.pushButton, QtWidgets.QPushButton) assert isinstance(ui.comboBox, _QComboBoxSubclass) -@pytest.mark.skipif(PYSIDE6, reason="Unavailable on PySide6") + def test_load_full_uic(): """Test that we load the full uic objects.""" QT_API = os.environ.get('QT_API', '').lower() From 62dc126d9d7c0522c8a9c5ae180b26b4e409b4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= Date: Mon, 18 Apr 2022 10:26:04 -0500 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: CAM Gerlach --- qtpy/tests/test_uic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qtpy/tests/test_uic.py b/qtpy/tests/test_uic.py index f873f1d2..a715dcbe 100644 --- a/qtpy/tests/test_uic.py +++ b/qtpy/tests/test_uic.py @@ -44,7 +44,7 @@ def enabled_qcombobox_subclass(temp_dir_path): @pytest.mark.skipif( sys.platform.startswith('linux') and not_using_conda(), - reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") + reason="Segfaults on Linux when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") def test_load_ui(qtbot): """ Make sure that the patched loadUi function behaves as expected with a @@ -64,7 +64,7 @@ def test_load_ui(qtbot): reason="PySide2uic not consistantly installed across platforms/versions") @pytest.mark.skipif( sys.platform.startswith('linux') and not_using_conda(), - reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") + reason="Segfaults on Linux when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") def test_load_ui_type(qtbot): """ Make sure that the patched loadUiType function behaves as expected with a @@ -90,7 +90,7 @@ def __init__(self): @pytest.mark.skipif( sys.platform.startswith('linux') and not_using_conda(), - reason="Segfaults on Linux CI when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") + reason="Segfaults on Linux when not using conda under all bindings (PYSIDE2/6 & PYQT5/6)") def test_load_ui_custom_auto(qtbot, tmp_path): """ Test that we can load a .ui file with custom widgets without having to From fab767aaa6e2e4c44835cb6cc2f1995e44847854 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 18 Apr 2022 10:57:40 -0500 Subject: [PATCH 3/5] Test: Increase default version for PyQt 6 to 6.3 --- .github/workflows/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh index 5f233445..98b7c76c 100755 --- a/.github/workflows/test.sh +++ b/.github/workflows/test.sh @@ -29,7 +29,7 @@ else if [ "${1}" = "pyqt5" ]; then pip install pyqt5==${PYQT5_VERSION:-"5.15"}.* PyQtWebEngine==${PYQT5_VERSION:-"5.15"}.* elif [ "${1}" = "pyqt6" ]; then - pip install pyqt6==${PYQT6_VERSION:-"6.2"}.* PyQt6-WebEngine==${PYQT6_VERSION:-"6.2"}.* + pip install pyqt6==${PYQT6_VERSION:-"6.3"}.* PyQt6-WebEngine==${PYQT6_VERSION:-"6.3"}.* elif [ "${1}" = "pyside2" ]; then pip install pyside2==${PYSIDE2_VERSION:-"5.12"}.* elif [ "${1}" = "pyside6" ]; then From d39d4d0f6d6014567e6f6a36f6b5bf77e3d318d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Althviz=20Mor=C3=A9?= Date: Tue, 19 Apr 2022 10:49:52 -0500 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: CAM Gerlach --- .github/workflows/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh index 98b7c76c..d86f790c 100755 --- a/.github/workflows/test.sh +++ b/.github/workflows/test.sh @@ -29,7 +29,7 @@ else if [ "${1}" = "pyqt5" ]; then pip install pyqt5==${PYQT5_VERSION:-"5.15"}.* PyQtWebEngine==${PYQT5_VERSION:-"5.15"}.* elif [ "${1}" = "pyqt6" ]; then - pip install pyqt6==${PYQT6_VERSION:-"6.3"}.* PyQt6-WebEngine==${PYQT6_VERSION:-"6.3"}.* + pip install pyqt6==${PYQT6_VERSION:-"6.3"}.* PyQt6-WebEngine==${PYQT6_VERSION:-"6.3"}.* PyQt6-Qt6==${PYQT6_QT_VERSION:-"6.3"}.* elif [ "${1}" = "pyside2" ]; then pip install pyside2==${PYSIDE2_VERSION:-"5.12"}.* elif [ "${1}" = "pyside6" ]; then From 6893baf646b0e227a7cf0bd376179bce8c1fd6a0 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 19 Apr 2022 11:38:38 -0500 Subject: [PATCH 5/5] CI: Enable testing PyQt6/PySide6 6.3 --- .github/workflows/ci.yml | 2 ++ .github/workflows/test.sh | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ab6a322..e19231c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,10 +52,12 @@ jobs: python-version: '3.10' use-conda: 'No' pyside2-version: '5.15' # No 5.12 wheel on Windows and Python 3.10 + pyside6-version: '6.3' - os: windows-latest python-version: '3.7' use-conda: 'Yes' pyqt5-qt-version: '5.9' + pyqt6-qt-version: '6.2' - os: macos-latest python-version: '3.7' use-conda: 'No' diff --git a/.github/workflows/test.sh b/.github/workflows/test.sh index d86f790c..adcd1002 100755 --- a/.github/workflows/test.sh +++ b/.github/workflows/test.sh @@ -33,7 +33,11 @@ else elif [ "${1}" = "pyside2" ]; then pip install pyside2==${PYSIDE2_VERSION:-"5.12"}.* elif [ "${1}" = "pyside6" ]; then - pip install pyside6==${PYSIDE6_VERSION:-"6.2"}.* + if [ "${PYSIDE6_VERSION:-"6.3":0:3}" = "6.3" ]; then + pip install pyside6==${PYSIDE6_VERSION:-"6.3"}.* pyside6-addons==${PYSIDE6_VERSION:-"6.3"}.* pyside6-essentials==${PYSIDE6_VERSION:-"6.3"}.* + else + pip install pyside6==${PYSIDE6_VERSION:-"6.2"}.* + fi else exit 1 fi