Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Save As bug #845

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()