← All extensions
Python Tests banner

Python Tests

ivyx

Adds pytest to the Test extension so you can run your Python tests and gate a pipeline on them

Python Tests

The pytest engine for the Test hub: run your project's tests from the panel, and use the same run as a gate that stops an MLOps pipeline when it is red.

What you can do

  • Run your project's test suite from a panel and read the counts at a glance
  • See one card per failing test, with the line that failed
  • List the tests without running them, when you only want to know what is there
  • Install pytest into your chosen environment in one click, and see which environment it went into
  • Add the same run to an MLOps pipeline as a gate, so a red suite stops the run before training

pytest is the real upstream tool — this extension manages it, it does not imitate it. Your tests stay ordinary pytest tests, your pytest.ini or pyproject.toml still decides how they run, and CI reads the same file.

Requirements

Desktop app (running processes), a Python environment from Python Environments, and pytest>=8,<10 in it. The panel installs it in one click and says which environment it is installing into.

As a pipeline gate

Add it to .punica/mlops.yaml and the MLOps hub runs it in order with the rest:

stages:
  - id: code-test
    kind: gate
    capability: test.pytest.run
    input:
      paths: ["tests"]
    onFailure: stop

  - id: train
    kind: pipeline

A failing test stops the run, train is recorded as skipped, and the reason names the test. The Test panel shows the same result, because both surfaces read the same capability rather than each keeping their own copy.

This is a gate you add once the pipeline runs. The walkthrough in the MLOps extension's README builds that pipeline from an empty folder; come back here to add the test gate to it.

What it reports

The verdict comes from pytest's own reporting hooks, not from its terminal output — your addopts, --tb setting or reporting plugin cannot change what the gate reads. The exit code is reported alongside for diagnosis, but two very different situations share exit 2, so it is never the verdict:

Situation Verdict
Everything passed pass
A test failed or a fixture raised fail, naming the test
A test module could not be imported fail, naming the module
No tests were collected error — a gate that collected nothing has checked nothing
pytest could not start (bad path, internal error) error, naming the paths

Set allowEmpty: true on the gate if an empty run should pass — for a repo that wants the gate in place before the tests are written.

Capabilities

id What it does
test.pytest.run Run the suite and report the verdict
test.pytest.discover List the tests without running them
test.pytest.engine Which pytest and Python are in the environment
test.pytest.reveal Open this panel

Getting started

Open Python Tests, pick the environment if you have not already, and press run. Listing tests without running them is a separate button, because collection imports every test module — that is your code, and it runs.