55except ImportError :
66 from strenum import StrEnum
77
8+ from pathlib import Path
9+
810import pytest
911from pydantic .fields import FieldInfo
1012from PyQt6 import QtWidgets
1113
1214from rascal2 .widgets import AdaptiveDoubleSpinBox , MultiSelectComboBox , MultiSelectList , get_validated_input
15+ from rascal2 .widgets .inputs import PathWidget
1316
1417
1518class MyEnum (StrEnum ):
@@ -26,6 +29,7 @@ class MyEnum(StrEnum):
2629 (FieldInfo (annotation = int ), QtWidgets .QSpinBox , 15 ),
2730 (FieldInfo (annotation = MyEnum ), QtWidgets .QComboBox , "value 2" ),
2831 (FieldInfo (annotation = str ), QtWidgets .QLineEdit , "Test string" ),
32+ (FieldInfo (annotation = Path ), PathWidget , str (Path ("." ).resolve ())),
2933 ],
3034)
3135def test_editor_type (field_info , expected_type , example_data ):
@@ -71,3 +75,17 @@ def test_multi_select_list_update(selected):
7175 buttons = msl .findChildren (QtWidgets .QToolButton )
7276 buttons [1 ].click ()
7377 assert msl .list .count () == 0
78+
79+
80+ def test_path_widget ():
81+ widget = PathWidget (None )
82+ assert widget .path == ""
83+ assert widget .text () == ""
84+
85+ widget .setText ("Browse..." )
86+ assert widget .text () == "Browse..."
87+
88+ path = Path ("." ) / "file.m"
89+ widget .setText (path )
90+ assert widget .path == path .parent .as_posix ()
91+ assert widget .text () == path .name
0 commit comments