Skip to main content

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)

  1. Hidden friendly runnercheck("translationproject") or the %%test cell magic. Runs the project's bundled tests against the student's translationproject.py and 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.
  2. Raw pytestpytest test_translationproject.py. The same file, now run with the real tool so students learn to read pytest's output. The sol fixture, the requires marker and the not-defined banner are provided automatically (this package registers a pytest11 plugin).
  3. 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

im_pytest-0.1.19.tar.gz (425.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

im_pytest-0.1.19-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file im_pytest-0.1.19.tar.gz.

File metadata

  • Download URL: im_pytest-0.1.19.tar.gz
  • Upload date:
  • Size: 425.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for im_pytest-0.1.19.tar.gz
Algorithm Hash digest
SHA256 5c9373099b40dffded5192286429022fc4b4e82501a833ee7978d914d82d7525
MD5 be19afe2ff93273108824e4b2efce2b5
BLAKE2b-256 45d615ff0834b7cb9ce6dfc7cbb52d665ed5576bbb0b2425eb2f74a49d30bdcc

See more details on using hashes here.

File details

Details for the file im_pytest-0.1.19-py3-none-any.whl.

File metadata

  • Download URL: im_pytest-0.1.19-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for im_pytest-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 6e74996fbc0d7e83f5b85653e5e42cb1f36472dbd70d1063eedc321da90d60c9
MD5 7cad6c1faed998ec3e2e8f3ea810eb57
BLAKE2b-256 11f6377f0a480053dd953231c23af54c3d9ae4cd7b36e338c2b972d8f3b46a70

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.33

2 files

0.1.32

2 files

0.1.29

2 files

0.1.27

2 files

0.1.25

2 files

0.1.23

2 files

0.1.21

2 files

This release

0.1.19 This release

2 files

0.1.18

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page