← 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

Requirements

  • The desktop app, because running tests starts processes.
  • A Python environment from Python Environments, with pytest 8 or 9 in it. The panel installs it for you and says which environment it is installing into.
  • The MLOps extension, if you want to use the suite as a pipeline gate.

Settings

The test.pytest.paths setting names the folders the panel's run button points pytest at. It is tests unless you change it; a pipeline gate names its own.

Getting started

Open Python Tests with Test: Python Tests Panel from the command palette, or from its row in the Test panel. If no environment is chosen yet, the panel offers Open Python Environments so you can pick one. Then press the run button, Run the test suite. List the tests without running them is a separate button, because listing imports every test module, and that is your code running.

Each failing test has a menu with Open test file and Run the suite again.

Good to know

  • Your tests stay ordinary pytest tests. Your pytest.ini or pyproject.toml still decides how they run, and CI reads the same file.
  • The verdict comes from pytest's own reporting, not its terminal output, so your flags and plugins cannot change what the gate reads.
  • A test module that cannot be imported fails the run and is named.
  • A run that collects no tests is an error rather than a pass, because a gate that collected nothing has checked nothing. A gate can be set to allow an empty run, for a repo that wants it in place before the tests are written.