Skip to content

Commit

Permalink
Add Separator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-yu committed Mar 17, 2024
1 parent 31395b1 commit 23f6753
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,37 @@ def f(x: Set[Lit]): ...
assert sel.choices == get_args(Lit)


def test_separator_default():
from magicgui.types import Separator

sep = Separator()
assert sep.thickness == 1


def test_separator():
from magicgui.types import Separator

sep = [Separator(i + 1) for i in range(4)]
a = [1, 2, sep[0], 4, sep[1], 6, 7, sep[2], 9, sep[3], 11, 12, sep[0], 14, sep[0]]
b = [1, 2, sep[0], 4, sep[1], 6, 7, sep[2], 9, sep[3], 6, 7, sep[0], 9, sep[0]]
a2 = (1, 2, None, 4, None, None, 6, 7, None, None, None, 9, None, None, None, None, 11, 12, None, 14, None)
b2 = (1, 2, None, 4, None, None, 6, 7, None, None, None, 9, None, None, None, None, None, None)

@magicgui(
call_button="Test Separator",
a={"widget_type": "ComboBox", "choices": a},
b={"widget_type": "ComboBox", "choices": b},
result_widget=True,
)
def widget_with_separator(a=a[0], b=b[0]):
return

assert widget_with_separator.a.native.count() == 21
assert widget_with_separator.b.native.count() == 18
assert widget_with_separator.a.choices == a2
assert widget_with_separator.b.choices == b2


def test_float_slider_readout():
sld = widgets.FloatSlider(value=4, min=0.5, max=10.5)
assert sld.value == 4
Expand Down

0 comments on commit 23f6753

Please sign in to comment.