fix(testing/ci/tooling): consistent unittest, venv guidance, runnable lab commands
- #9: standardize the test chain on stdlib unittest (nothing-to-install, which keeps M13's claims true and its planted bug intact). Aligned M5/M14/M16 prose, M14 lab/test_tasks.py, and ci/gitlab starters; ruff stays the only pip install. - #20: add venv / PEP 668 / which-python guidance to M20 (+ M14/M15 local installs); point MCP config at the venv's absolute python. - #21: replace M21 Part D's empty `git diff HEAD~1` with `git log -p` (no .gitignore added — device preserved). - #22: add a dependency-install step before M23's green baseline on a fresh clone. - #23: M24 reviewer/triage now tolerate code-fence-wrapped JSON (stdlib only); feature.patch trap untouched. - #28: fix M27 Part D CI snippet path (working-directory) and require the gate to target a varying candidate; swapped_model regression kept as the fixture. Closes #9 Closes #20 Closes #21 Closes #22 Closes #23 Closes #28 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfzV5QvtPDz8LJS3Pu5VLT
This commit is contained in:
@@ -1,36 +1,41 @@
|
||||
"""Tests for the tasks-app core logic — the kind of suite Module 13 has you write.
|
||||
|
||||
Reproduced here so this module's lab is self-contained: if you already wrote tests in Module 13,
|
||||
use those instead. Run locally with `pytest -q` from the project folder. CI runs exactly this.
|
||||
use those instead. Standard-library `unittest`, exactly like Module 13 — nothing to install.
|
||||
Run locally with `python -m unittest` from the project folder. CI runs exactly this.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from tasks import TaskList
|
||||
|
||||
|
||||
def test_add_appends_a_task():
|
||||
tl = TaskList()
|
||||
tl.add("write the CI lesson")
|
||||
assert len(tl.tasks) == 1
|
||||
assert tl.tasks[0].title == "write the CI lesson"
|
||||
assert tl.tasks[0].done is False
|
||||
class TestTaskList(unittest.TestCase):
|
||||
def test_add_appends_a_task(self):
|
||||
tl = TaskList()
|
||||
tl.add("write the CI lesson")
|
||||
self.assertEqual(len(tl.tasks), 1)
|
||||
self.assertEqual(tl.tasks[0].title, "write the CI lesson")
|
||||
self.assertFalse(tl.tasks[0].done)
|
||||
|
||||
def test_complete_marks_a_task_done(self):
|
||||
tl = TaskList()
|
||||
tl.add("ship it")
|
||||
tl.complete(0)
|
||||
self.assertTrue(tl.tasks[0].done)
|
||||
|
||||
def test_pending_excludes_completed_tasks(self):
|
||||
tl = TaskList()
|
||||
tl.add("a")
|
||||
tl.add("b")
|
||||
tl.complete(0)
|
||||
pending = tl.pending()
|
||||
self.assertEqual(len(pending), 1)
|
||||
self.assertEqual(pending[0].title, "b")
|
||||
|
||||
def test_render_is_friendly_when_empty(self):
|
||||
self.assertEqual(TaskList().render(), "(no tasks yet)")
|
||||
|
||||
|
||||
def test_complete_marks_a_task_done():
|
||||
tl = TaskList()
|
||||
tl.add("ship it")
|
||||
tl.complete(0)
|
||||
assert tl.tasks[0].done is True
|
||||
|
||||
|
||||
def test_pending_excludes_completed_tasks():
|
||||
tl = TaskList()
|
||||
tl.add("a")
|
||||
tl.add("b")
|
||||
tl.complete(0)
|
||||
pending = tl.pending()
|
||||
assert len(pending) == 1
|
||||
assert pending[0].title == "b"
|
||||
|
||||
|
||||
def test_render_is_friendly_when_empty():
|
||||
assert TaskList().render() == "(no tasks yet)"
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user