Skip to content
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

PR: Fix uic skipped tests and PyQt 6.3.0 segfaulting tests #335

Merged
merged 5 commits into from
Apr 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 15 additions & 37 deletions qtpy/tests/test_uic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -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)")
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
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)

Expand All @@ -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)")
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
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'

Expand All @@ -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)")
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
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()
Expand Down