Skip to content

Commit

Permalink
do not use native dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Oct 21, 2024
1 parent 208421d commit f38e780
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package/PartSeg/common_gui/custom_load_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ class LoadProperty(typing.NamedTuple):
class IOMethodMock:
__new_style__ = False

__fields__: typing.ClassVar[dict[str, typing.Any]] = {}

def __init__(self, name: str):
self.name = name

def __call__(self, *args, **kwargs):
return self

def get_name(self) -> str:
return self.name

Expand Down
7 changes: 5 additions & 2 deletions package/tests/test_PartSeg/test_common_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,11 @@ def test_p_load_dialog(part_settings, tmp_path, qtbot, monkeypatch):
assert [Path(x) for x in part_settings.get_path_history()] == [tmp_path, Path.home()]


def test_str_filter(part_settings, tmp_path, qtbot, monkeypatch):
def test_str_filter_save(part_settings, tmp_path, qtbot, monkeypatch):
tiff_text = "Test (*.tiff)"
monkeypatch.setattr(QFileDialog, "result", lambda x: QFileDialog.Accepted)
monkeypatch.setattr(QFileDialog, "selectedFiles", lambda x: [str(tmp_path / "test.tif")])
dialog = PSaveDialog(tiff_text, settings=part_settings, path="io.save_test")
dialog = PSaveDialog(tiff_text, settings=part_settings, path="io.save_test", system_widget=False)
qtbot.addWidget(dialog)
assert tiff_text in dialog.nameFilters()
dialog.show()
Expand All @@ -546,6 +546,9 @@ def test_str_filter(part_settings, tmp_path, qtbot, monkeypatch):
assert dialog.selectedNameFilter() == tiff_text
assert [Path(x) for x in part_settings.get_path_history()] == [tmp_path, Path.home()]


def test_str_filter_load(part_settings, tmp_path, qtbot, monkeypatch):
tiff_text = "Test (*.tiff)"
with (tmp_path / "test2.tif").open("w") as f:
f.write("eeeeeee")

Expand Down

0 comments on commit f38e780

Please sign in to comment.