Skip to content

Commit fc29e6b

Browse files
authored
Merge pull request #212 from hanjinliu/open-py
Fix model type of python files
2 parents 3a715f7 + bd5b967 commit fc29e6b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/himena_builtins/_io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def _infer_separator(file_path: Path, encoding: str | None = None) -> str:
5454
def default_text_reader(file_path: Path) -> WidgetDataModel:
5555
"""Read text file."""
5656
suffix = file_path.suffix.rstrip("~")
57-
if suffix in (".html", ".htm"):
57+
if suffix == ".py":
58+
typ = StandardType.PYTHON
59+
elif suffix in (".html", ".htm"):
5860
typ = StandardType.HTML
5961
elif suffix == ".json":
6062
typ = StandardType.JSON

tests/test_sub_windows.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def test_builtin_commands(himena_ui: MainWindow):
7777
himena_ui.exec_action("builtins:new-text-python")
7878
with choose_one_dialog_response(himena_ui, "Copy"):
7979
himena_ui.exec_action("show-about")
80+
win = himena_ui.read_file(Path(__file__))
81+
assert win.model_type() == StandardType.PYTHON
8082
himena_ui.exec_action("quit")
8183

8284

@@ -521,7 +523,7 @@ def test_open_and_save_files(himena_ui: MainWindow, tmpdir, sample_dir: Path):
521523
assert isinstance(himena_ui.tabs[0][-1].to_model().workflow.last(), LocalReaderMethod)
522524

523525
image_value = np.arange(5 * 20 * 15 * 3, dtype=np.uint8).reshape(5, 20, 15, 3)
524-
himena_ui.add_object(image_value, type="array.image")
526+
himena_ui.add_object(image_value, type=StandardType.IMAGE)
525527
save_path = tmpdir / "array_image.gif"
526528
with file_dialog_response(himena_ui, save_path):
527529
himena_ui.exec_action("save-as")

0 commit comments

Comments
 (0)