pyathy
Test a Python command-line program with scenarios written in plain English.
You write .feature files (Gherkin: Scenario, When, Then) that type answers into
the program, fix its dice rolls, and check what it prints. pyathy runs each scenario against
a fresh start of main.py and shows each run, then one ✔/✘ line per scenario plus a total.
It is built on pytest-bdd and needs Python 3.11+.
It was built for the Saxion ADSD python course, so that the acceptance tests of an assignment can be read, and written, by people new to programming: the steps are the words a person would use at the keyboard, and no code is needed. It tests any Python command-line program, anywhere, the same way.
Ruby has this layer already: Aruba gives Cucumber ready-made steps for command-line programs (run it, type this, expect that output). Python's pytest-bdd has no such layer; pyathy is that layer for Python.
Install and use
Four ways to get the command. They run the same features the same way.
From PyPI, as a command on your PATH:
pipx install pyathy # or: uv tool install pyathy
or inside a project's venv: pip install pyathy. For VS Code there is the pyathy extension,
MB42.pyathy in the Marketplace.
No install: the pyathy/ folder next to main.py. The folder is built from this repo by
scripts/build-folder.sh into dist/pyathy/, with pytest-bdd inside, so nothing needs installing:
my-game/
main.py
features/
game.feature
pyathy/
python pyathy
In a course, an assignment's package is this folder plus its features/, zipped.
Poetry, with that same pyathy/ folder in the project:
poetry add ./pyathy
poetry run pyathy
pip, in a venv: pip install ./pyathy for the folder, or from a clone of this repo:
python -m venv .venv
.venv/bin/pip install . # Windows: .venv\Scripts\pip install .
cd examples/tictactoe
../../.venv/bin/pyathy # Windows: ..\..\.venv\Scripts\pyathy
That runs the tic-tac-toe example's features against its main.py.
From the folder that holds main.py and features/ (write python pyathy … for the folder,
poetry run pyathy … under Poetry):
pyathy run every features/*.feature against main.py
pyathy features/x.feature run only that file (or folder)
pyathy check find mistakes in the feature files, without running main.py
pyathy init create features/hello.feature (and a main.py) to start from
pyathy steps every step you can use (plus your own, from features/*_steps.py)
pyathy -h usage and an example feature
Options, each with a short and a long form:
-q, --quiet only one line per scenario (a ✘ gets one reason line) and the total
-ff, --fail-fast stop at the first scenario that fails
-nf, --next-failure run the scenarios that failed last time, in order, stopping at the first that still fails
-s, --solution [FOLDER] run the features here against ./_solution/main.py, or ./FOLDER/main.py (-s obj2 means _solution-obj2)
-o, --output show|hide|slow the program's output in the report: show it (the default), hide it, or slow: a line at a time, to read along (on a terminal only)
--delay SECONDS the pause after each line under -o slow (default 0.1: a 100-line run takes 10 seconds; --delay alone means -o slow)
-h, --help this help
-v, --version pyathy's version and where it runs from
The report shows each scenario's run as a terminal would have (what was printed, what was
typed), then its ✔/✘ line with the reason under a ✘, a summary per feature, and the last
line TOTAL n of m; -q keeps only the ✔/✘ lines and the total. Every report ends with
pyathy <version> · <where it runs from>, the same as -v, so two copies on one machine are
never confused. -nf reads the failures remembered in .pyathy/last-run.json; -s is for
the teacher's folder, where the reference program sits in _solution/. The report's colours,
the long-run cut and the details of -nf and -s: docs/running.md.
pyathy check reads the feature files without running the program and lists, per file,
what would stop a scenario before it starts: a line no step matches (with the closest step,
did you mean: I input Ada), a file that is not valid Gherkin, a scenario or step indented
differently from the others, and a file step pyathy cannot find in the program. It exits with
1 when it found something; --json prints the same for an editor (the pyathy VS Code
extension uses it). Details and sample output: docs/check.md.
A first feature
Feature: Tic Tac Toe
Scenario: X wins with the top row
When I input 1, 4, 2, 5, 3
Then "Player X wins!" is printed
And the program asks "Play again? (y/n)"
A Scenario is one run of the program, from a fresh start. When lines act (type answers,
roll dice) and Then lines check what the program did; And continues the line before it.
Built-in steps, or your own
The built-in steps are the keyboard and the screen: type an answer, make the die show a
face, check what was printed, check a file. They need no code, so a feature can be read and
written by someone who has never seen a test; examples/tictactoe uses nothing else.
Your own steps speak the program's own language instead (Ann has $1440, Ann owns Harbour): a few lines of Python each, in a features/*_steps.py, worth writing once a feature
file starts repeating the same five built-in lines to say one thing.
Each built-in works after Given, When, Then, And or But. Text checks ignore case and
trailing spaces. Colours in the program's output (\033[31m-style codes) are ignored when
matching, and shown in the report. python pyathy steps prints this list (colour-coded on
a terminal: the parts you replace in cyan).
Each step has its own page under docs/, with what it checks, when it is
needed, a scenario that runs and the message it fails with. Two guides: turn-based
games (red rolls 6, red moves from 0 to 3) and starting from a saved
state (a saved game:, the program is started again).
| Step | What it does |
|---|---|
I start the program / I run the program with puzzle.txt --hard |
run main.py until it asks something or ends; with … starts it with these command-line arguments |
the program other.py |
run other.py instead of main.py |
the program may take 30 seconds |
wait longer for a slow program (default 10) |
main.py has DEBUG = True |
before it starts, set DEBUG = … at the top of main.py to this Python value (in the copy; your file stays as it is) |
main.py has a DEBUG setting |
main.py has DEBUG = … at the top, outside any function (only checks it is there; sets nothing) |
I input 4 / I input 4, left, no |
type answers, one per question |
I input enter / I input enter, q |
press enter, on its own or as one answer of the list (quote "enter" to type the word) |
I roll 6 / I roll 3 and 4 |
the next dice show these faces |
the random choice is red |
the next random pick returns this value |
the dice show 2, 4, 1 |
a line printed has these faces in this order, any separators but digits between them (2 4 1, [2, 4, 1]), no digit right next to them |
red rolls 6 / Ann rolls 4+6 |
I input enter (if the program is waiting for it) then I roll 6, after checking it is red's turn: the last line announcing a turn names red and no other player, without digits (Player red:) |
red rolls 3 and picks 2 / … and answers 2 |
the same, then types 2 at the question that follows |
these turns are played 3 times: + a table |
one step per row (| red rolls 5 |), run in order, that many times |
the players are red and green |
the names a turn announcement may use (otherwise: the names typed or rolled for so far) |
red's turn is announced / it is red's turn |
a line names red and no other player, without digits |
a pawn moves from 0 to 3 / red moves from 0 to 3 |
a line of this turn (since the last roll) has these two numbers, to or an arrow between them |
nothing moves |
no such line this turn |
Kim is named the winner |
a line printed names Kim, and no other player, and has won, wins, winner or win (case ignored) |
"Hello" is printed |
somewhere in the output |
"Error" is printed 3 times |
exactly that many times |
"Game over" is not printed |
nowhere in the output |
the output starts with "Welcome" |
the very first output |
the output shows: + lines between """ |
these lines, in a row |
the line with "Total" also has "42" |
the last line printed with Total in it also has 42 |
the "Bob" row has "7" under "Score" / … has nothing under "Score" |
in the last table printed with a Score column (cells split by │ or |; tables lined up with spaces are not read), Bob's row has 7 there, or nothing |
the program asks "Your name?" |
it is now waiting for input after that question |
"orange" is refused with a message |
after typing it, a message was printed and the same question was asked again (a menu printed every time is not the message; "" is pressing enter) |
the program ends / the program is still running |
|
a file "photos/beach.jpg" |
an empty file in the folder before the program starts (its folders made too) |
a file "game.txt" containing "round 3" |
put this one-line file in the folder before the program starts |
a file "game.txt" with: + lines between """ |
the same, several lines |
there is no file "game.txt" |
the program starts without it, whatever is in your folder (a saved game from playing, say) |
a file "game.txt" is written / no file is written |
the program made a file, or changed one |
the file "game.txt" contains "round 4" |
anywhere in the file |
the file "game.txt" contains: + lines between """ |
these lines, in a row |
a saved game: + lines between """ |
these lines are in the program's save file before it starts |
there is no saved game |
the program starts without its save file |
a saved game is written |
the program made its save file, or changed it |
the saved game holds: + lines between """ |
these lines, in a row, in the save file |
no saved game is left |
the save file was removed, or emptied |
the program is started again |
stop it and start it over in the same folder, so the files it wrote are still there |
Your own steps
Every *_steps.py next to the .feature files is loaded. A step is a pattern in
Cucumber style: {name} matches anything,
{name:w} one word, {n:d} a whole number, and each field becomes a parameter of the function.
program.settle() returns everything printed so far; fail(program, message) fails the step
with the program's last lines under the message.
examples/monopoly/features/monopoly_steps.py adds Ann has $1460 and Ann owns Harbour:
from pyathy.steps import fail, step
@step("{name:w} has ${cash:d}")
def has(program, name, cash):
...
python pyathy steps lists them under the built-ins, as written. The whole of it, with the
step above in full: docs/own-steps.md.
Pull an assignment's features
In a folder lms grade opened, _node links to the assignment in the curriculum and _solution
to its solutionN/. Next to solutionN/ and templateN/, the curriculum keeps featuresN/:
pyathy pull copy <_node>/featuresN/ into features/ (N from the _solution link)
pyathy run features/
A pull into a folder that already has features/ is refused unless --force.
Every pull, from the curriculum or a locked file, leaves one line in features/pulled.txt: when,
by which pyathy, what it pulled, and a fingerprint of the files (12 characters of their sha256;
the same files give the same fingerprint, wherever they came from):
pulled 2026-11-16 10:12 by pyathy 0.1.21: features2/ of lists at curriculum commit 4fd3e58, fingerprint 2f61c0e9a4b8
pulled 2026-11-16 10:12 by pyathy 0.1.21: variant 2 of python-exam, locked 2026-11-02 09:40 by pyathy 0.1.21, fingerprint 7b3d70192511
The curriculum commit is the last one that touched featuresN/ (plus uncommitted changes when
the folder differs from it; left out when the curriculum is not a git checkout). A pull --force
replaces features/ and the note with it. A plain pyathy ignores the note.
Exams: lock and pull
An exam's features are not handed out; they stay in one password-locked file per exam, holding every variant. The teacher who writes the exam locks it once:
pyathy lock python-exam variants/ variants/ holds 1/, 2/, … each with its .feature and *steps.py files
It asks the password twice and writes python-exam.pyathy-locked into the store: the folder
$PYATHY_STORE, or ~/.pyathy/locked/ when that is not set. An existing file is overwritten only
after a yes, or with --force. Colleagues who grade get a copy of that file and the password.
When the store is a git repo (a clone the teachers share), pyathy keeps it fresh: pyathy lock
commits the file it wrote ("lock ") and pushes, and pyathy pull runs git pull --ff-only
first. When git fails (offline, no remote), one pyathy: warning: line says so and the local copy
is used; a lock stays committed and goes up with the next push.
In the folder a grading tool opened for one attempt, named like student@python-exam~1 (the exam
is read from the part between @ and ~):
pyathy pull list the exam's variant numbers (no password needed)
pyathy pull 2 ask the password, put variant 2's files into features/
pyathy run features/
A pull into a folder that already has features/ is refused unless --force, which replaces the
whole features/ folder.
For scripts, the password may come from $PYATHY_PASSWORD; it is never printed.
The locked file carries a stamp, readable without the password: when it was locked, by which
pyathy, and each variant's fingerprint. pyathy lock and a pyathy pull without a number print it:
locked 2026-11-02 09:40 by pyathy 0.1.21; fingerprints 1: cd663cb8515c, 2: 7b3d70192511
A file locked before the stamp (pyathy 0.1.20 and earlier) has none and still pulls.
What the lock does: without the password, the file shows only how many variants there are,
their numbers and the stamp; changing the stamp makes the file read as damaged; a wrong password or a damaged file is refused (wrong password or damaged file)
before anything is written. It uses Python's standard library only (scrypt for the key, an
HMAC-SHA256 keystream, an HMAC-SHA256 tag), so nothing needs installing.
What it does not do: once pulled, the files are plain text in that folder, readable by anyone who
can read the folder; and anyone with the password and the file can read every variant. Keep the
password with the people who grade, and remove features/ when grading is done if the folder
travels further.
Examples
examples/tictactoe (built-in steps only), examples/sudoku (boards checked with
the output shows:, a puzzle file as argument) and examples/monopoly (dice and its own
steps). examples/edge fails on purpose, to show the messages. Run them all with
scripts/try-examples.sh.
License
MIT, see LICENSE.
Metadata
Release files for pyathy 0.1.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyathy-0.1.22.tar.gz | 59.6 kB | With provenance | Details for pyathy-0.1.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyathy-0.1.22-py3-none-any.whl | Python 3 | none | any | Details for pyathy-0.1.22-py3-none-any.whl |
Total release size: 119.3 kB
Release files / pyathy-0.1.22.tar.gz
| Download URL | pyathy-0.1.22.tar.gz |
|---|---|
| Size | 59.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b22f21b233d3a1a82fbb85577507daead03016e12d3b9a4a2c4ab316da21014b
|
|
BLAKE2b-256 checksum How to use checksums |
5f31bf6c9f635f44c6b06b66885c0b57a49361e924ac43a4c9665bb10c64f565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / pyathy-0.1.22-py3-none-any.whl
| Download URL | pyathy-0.1.22-py3-none-any.whl |
|---|---|
| Size | 59.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85e5276542de7852005021c4eb362c7f5e637c9ee1fd39ab27a3ffc1e05af4e2
|
|
BLAKE2b-256 checksum How to use checksums |
66c7cd6358d8f90ac7d2cfb4439865bd5f9b9f8c7a9df00dc56fc217f21d0aac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for pyathy 0.1.22
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyathy-0.1.22.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.