Skip to content

Commit

Permalink
Fix Save As bug (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys authored Jul 19, 2022
1 parent 5bf218e commit 254759d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions sleap/gui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ def _try_save(context, labels: Labels, filename: str):
success = False
try:
extension = (PurePath(filename).suffix)[1:]
extension = None if (extension == "slp") else extension
Labels.save_file(labels=labels, filename=filename, as_format=extension)
success = True
# Mark savepoint in change stack
Expand Down
15 changes: 15 additions & 0 deletions tests/gui/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,18 @@ def OpenSkeleton_ask(context: CommandContext, params: dict) -> bool:
assert params["filename"] == fly_legs_skeleton_json
OpenSkeleton.do_action(context, params)
assert_skeletons_match(new_skeleton, stickman)


def test_SaveProjectAs(centered_pair_predictions: Labels, tmpdir):
"""Test that project can be saved as default slp extension"""

context = CommandContext.from_labels(centered_pair_predictions)
# Add fake method required by SaveProjectAs.do_action
context.app.__setattr__("plotFrame", lambda: None)
params = {}
fn = PurePath(tmpdir, "test_save-project-as.slp")
params["filename"] = str(fn)
context.state["labels"] = centered_pair_predictions

SaveProjectAs.do_action(context=context, params=params)
assert Path(params["filename"]).exists()

0 comments on commit 254759d

Please sign in to comment.