Skip to content

Commit

Permalink
fix tests that fatally crash on PySide6
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Mar 11, 2022
1 parent 78dcf93 commit 539eb4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 9 additions & 4 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,15 @@ def assert_rgba(c, r, g, b, a):
assert_rgba(convert.to_qcolor((34 / 255., 58 / 255., 129 / 255.)), 34, 58, 129, 255)
assert_rgba(convert.to_qcolor((34 / 255., 58 / 255., 129 / 255., 0.45)), 34, 58, 129, 114)

# wrong number of arguments
for obj in [(1, 2), (1, 2, 3, 4, 5, 6, 7)]:
with pytest.raises(TypeError):
convert.to_qcolor(obj)
# wrong number of arguments (get fatal crash with PySide6 during tests)
if binding.name != 'PySide6':
for obj in [(1, 2), (1, 2, 3, 4, 5, 6, 7)]:
with pytest.raises(TypeError):
convert.to_qcolor(obj)

# wrong type
with pytest.raises(TypeError, match=r'Cannot convert \(None,\) to a QColor'):
convert.to_qcolor(None)


def test_number_to_si():
Expand Down
12 changes: 9 additions & 3 deletions tests/test_spinboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import pytest

from msl.qt import QtGui
from msl.qt import (
binding,
QtGui,
)
from msl.qt.widgets import spinboxes
from msl.qt.constants import GREEK

Expand Down Expand Up @@ -113,8 +116,11 @@ def test_doublespinbox():
assert dsb.toolTip() == 'hi'
dsb.setValue(9876)
assert dsb.value() == 9876.0
with pytest.raises(TypeError):
dsb.setValue('12n') # cannot us SI prefix

# wrong number of arguments (get fatal crash with PySide6 during tests)
if binding.name != 'PySide6':
with pytest.raises(TypeError):
dsb.setValue('12n') # cannot us SI prefix

dsb = spinboxes.DoubleSpinBox(use_si_prefix=True)
assert dsb.minimum() == 0.0
Expand Down

0 comments on commit 539eb4b

Please sign in to comment.