1.5 just test
Read the tutorial. Build it yourself is the other way to read this part.
This walk goes through rahuldave/cheesecracker on GitHub. This part starts from the code at cbc98b162671, partway through step-01. The code before this part
To look at this code on your machine, run these commands. The first one makes a clone, if this folder has none:
[ -d cheesecracker ] || git clone https://github.com/rahuldave/cheesecracker
cd cheesecracker
git fetch --quiet --tags --force origin
git switch --detach cbc98b162671just setupThe whole tutorial first writes the function power(), and adds pytest, a program that
runs tests. It tells pytest where the tests are, and writes eleven unit tests. The command that runs them gets a recipe.
1.5 just test runs the tests
The command uv run pytest is long, and every task of the project gets a recipe in the justfile, so that one
short command runs it. The recipe test runs pytest through uv, and passes on to pytest any words that you type after just test.
The recipe test, at the end of the justfile, runs uv run pytest "$@". "$@" stands for the words after
just test, so just test tests/unit runs the unit tests alone.
just test -qjust prints the command of the recipe, and pytest prints 11 passed.
What changed
justfile: the recipetest. 4 lines added. The file- look at
uv run pytest "$@"
- look at
The diff of justfile
@@ -10,3 +10,7 @@ default:
# Install Python and every dependency into .venv, exactly as the lockfile says
setup:
uv sync --locked
+
+# Run the tests. Extra arguments go to pytest: just test tests/unit
+test *args:
+ uv run pytest "$@"This part ends at the code at step-01. The code after this part