1.5 just test

Build it yourself. Read the tutorial 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

This part does not start where the part before it ends, because the walk skips some changes. This command puts the files that this part starts from in place of yours. Run it, and then go on:

git fetch --quiet --tags --force origin; git restore --source step-00 --staged -- :/ && git restore --source cbc98b162671 --staged --worktree -- :/

If you start at this part, make your clone as Get the project says, and then run this command. It puts in your clone the files that this part starts from. A file that the project deleted before this part stays, so delete it if git check lists it:

git rm -rq --cached --ignore-unmatch -- :/ && git restore --source cbc98b162671 --staged --worktree -- :/
just setup

The 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.

Apply the patch to justfile, from the top of the project:

curl -fsSL https://github.com/rahuldave/cheesecracker/commit/e86e0c3d10bbe9409674f1c65ce4afdc38e7f76f.diff | git apply --include=justfile

Read the recipe test at the end of the justfile.

just test -q

just prints the command of the recipe, and pytest prints 11 passed.

Check your files against this move. The command prints nothing when they match, and otherwise shows what differs:

git check e86e0c3d10bb

If you are stuck, this command puts the files of this move in place of yours. A file that you made yourself stays:

git fetch --quiet --tags --force origin; git restore --source cbc98b162671 --staged -- :/ && git restore --source step-01 --staged --worktree -- :/

What changed

  • justfile: the recipe test. 4 lines added. The file
    • look at uv run pytest "$@"

The patch to 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 change on GitHub

This part ends at the code at step-01. The code after this part