Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/python_learning_orchestrated/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ def main(
if args.checkpoint_command == "list":
checkpoints = checkpoint_store.list_checkpoints()
if not checkpoints:
output_fn("No checkpoints found.")
output_fn(
"No checkpoints found. Use 'checkpoint create <name>' to save "
"your progress."
)
return
output_fn(f"Checkpoints ({len(checkpoints)}):")
for checkpoint in checkpoints:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cli_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ def test_cli_export_and_import_progress_commands(tmp_path, capsys) -> None:
assert len(session_payload["attempts"]) == 1


def test_cli_checkpoint_list_empty(capsys) -> None:
main(["checkpoint", "list"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Isolate empty-checkpoint test from persisted user state

Make this smoke test use a temporary checkpoint directory (as the other checkpoint tests do) instead of calling main(["checkpoint", "list"]) against the real default store. CheckpointStore() writes/reads ~/.config/python-learning-orchestrated/checkpoints (default_checkpoint_directory()), so this assertion only holds on machines with no existing checkpoints and can fail for developers who have used the CLI before, making the test non-hermetic and flaky outside clean CI environments.

Useful? React with πŸ‘Β / πŸ‘Ž.

output = capsys.readouterr().out
assert (
"No checkpoints found. Use 'checkpoint create <name>' to save your progress."
in output
)
Comment on lines +97 to +100

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For a more precise test, it's better to assert the exact output rather than using in. This ensures no other unexpected text is printed. You can compare against the stripped output for a cleaner assertion, which makes the test more robust.

    assert output.strip() == (
        "No checkpoints found. Use 'checkpoint create <name>' to save your progress."
    )



def test_cli_checkpoint_create_and_list(tmp_path, capsys, monkeypatch) -> None:
session_file = tmp_path / "session.json"
checkpoint_dir = tmp_path / "checkpoints"
Expand Down
Loading