Run the Instructing Machines project tests three ways: a friendly hidden runner (check() / %%test), the raw pytest CLI, and student-authored tests.
Project description
im-pytest
A thin runner over pytest for the Instructing Machines course. One set of per-project test files is surfaced three escalating ways across the term, so testing grows from a hidden safety net into a tool students wield themselves.
import im_pytest
im_pytest.check("translationproject") # friendly panel: ✓/✗ per function
The three modes (one artifact)
- Hidden friendly runner —
check("translationproject")or the%%testcell magic. Runs the project's bundled tests against the student'stranslationproject.pyand renders a beginner-friendly panel: a green ✓ or red ✗ per function, the failing assertion, and a "functions not defined yet" note. No test source, no traceback. For the early weeks, before students know what a test is. - Raw pytest —
pytest test_translationproject.py. The same file, now run with the real tool so students learn to read pytest's output. Thesolfixture, therequiresmarker and the not-defined banner are provided automatically (this package registers apytest11plugin). - Student-authored — students write their own
assert-based tests to specify and validate AI-produced code, using the provided files as the model.
There is also a terminal entry point:
pytest-check translationproject.py # or: pytest-check translationproject
Writing a project test file
Per-project test files are plain, idiomatic pytest. They receive sol (the
student's solution module, imported fresh with the student's own print output
suppressed) and mark each test with requires so an unwritten function is
reported as "not defined" instead of crashing:
import pytest
@pytest.mark.requires("translate_codon")
def test_translate_codon(sol):
assert sol.translate_codon("ATG") == "M"
assert sol.translate_codon("NNN") == "?" # invalid codon
assert sol.translate_codon("atg") == "M" # lowercase
sol resolves to <project>.py in the working folder (the module name is the
test file name minus its test_ prefix). Project test files and their data live
in the course repository and are distributed to students as downloads; set
IM_PROJECT_TESTS to point the runner at a shared folder instead of the working
directory.
Development
pixi run install-dev
pixi run test
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file im_pytest-0.1.18.tar.gz.
File metadata
- Download URL: im_pytest-0.1.18.tar.gz
- Upload date:
- Size: 425.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd30debe340ac46a74f14bb247b533bdaca902bb7953d306244aa05a7ad02bf8
|
|
| MD5 |
3ce4fb7b332cf27bc0949a4089d55a60
|
|
| BLAKE2b-256 |
7820146df07b6dfd91b87fd1cfdfe95ff211ad32dd471c6ef0ffb58334d88199
|
File details
Details for the file im_pytest-0.1.18-py3-none-any.whl.
File metadata
- Download URL: im_pytest-0.1.18-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0356fa9550c9aa577d0ec70939362fd1ef315877da623d9a28d2db62d87a5a
|
|
| MD5 |
96d72df79408eff71c10d32bf1a5d349
|
|
| BLAKE2b-256 |
ceb4987cd9b57580768019470dc69d80f9e2c54bc2f322586d3ac2f5b0306e27
|