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: 3 additions & 2 deletions pythonlings/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def _cmd_hint(root: Path, name: str) -> int:


def _cmd_run(root: Path, name: str) -> int:
from pythonlings.core.exercise import Exercise
from pythonlings.core.manifest import load as load_manifest
from pythonlings.core.runner import run as run_exercise

Expand All @@ -291,8 +292,8 @@ def _cmd_run(root: Path, name: str) -> int:
return 1
if ex.is_pending():
sys.stderr.write(
"pythonlings: tests pass but the '# I AM NOT DONE' marker "
f"is still in {name}.\n"
"pythonlings: tests pass but the "
f"'{Exercise.DONE_MARKER}' marker is still in {name}.\n"
)
return 1
return 0
Expand Down
50 changes: 50 additions & 0 deletions tests/test_cli_done_marker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from __future__ import annotations

from pathlib import Path

from pythonlings.core.exercise import Exercise


def test_run_message_references_done_marker(tmp_path: Path, monkeypatch, capsys):
"""The CLI's pending-marker message must track Exercise.DONE_MARKER."""
from pythonlings import cli

exercise_path = tmp_path / "exercise.py"
exercise_path.write_text(
f"{Exercise.DONE_MARKER}\nprint('hi')\n", encoding="utf-8"
)
check_path = tmp_path / "check.py"
check_path.write_text("", encoding="utf-8")

ex = Exercise(
name="demo",
path=exercise_path,
check_path=check_path,
topic="basics",
hint="",
)

class FakeManifest:
def by_name(self, name: str) -> Exercise:
assert name == "demo"
return ex

class FakeResult:
stdout = ""
stderr = ""
timed_out = False
exit_code = 0
duration_s = 0.0

monkeypatch.setattr(
"pythonlings.core.manifest.load", lambda root: FakeManifest()
)
monkeypatch.setattr(
"pythonlings.core.runner.run", lambda exercise: FakeResult()
)

exit_code = cli._cmd_run(tmp_path, "demo")
captured = capsys.readouterr()

assert exit_code == 1
assert Exercise.DONE_MARKER in captured.err
Loading