Testing/CI/tooling consistency (#9,#20,#21,#22,#23,#28) (#59)

Co-authored-by: claude <claude@jpaul.io>
Co-committed-by: claude <claude@jpaul.io>
This commit was merged in pull request #59.
This commit is contained in:
2026-06-22 16:07:58 -04:00
committed by Claude (agent)
parent a6a3cfdc50
commit 391df7fc6d
17 changed files with 216 additions and 82 deletions
@@ -33,14 +33,16 @@ jobs:
with:
python-version: "3.12"
# Step 3: install the tools the checks need — the test runner and the linter from Module 13.
# Step 3: install the linter (ruff), the new tool this module adds. The test runner is
# Python's standard-library unittest from Module 13 — nothing to install for it.
- name: Install tools
run: pip install pytest ruff
run: pip install ruff
# Step 4: lint. Style and obvious-mistake check. Fails the job on any finding (non-zero exit).
- name: Lint
run: ruff check .
# Step 5: test. The Module 13 tests. A single failing assertion fails the whole job.
# Step 5: test. The Module 13 tests, run with the stdlib unittest runner. A single failing
# assertion fails the whole job.
- name: Test
run: pytest -q
run: python -m unittest
@@ -17,6 +17,6 @@ check:
# of "runs-on: ubuntu-latest" plus "set up Python".
image: python:3.12
script:
- pip install pytest ruff
- ruff check . # lint
- pytest -q # test
- pip install ruff
- ruff check . # lint
- python -m unittest # test (stdlib runner from Module 13 — nothing to install)
@@ -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()