Skip to content

Pytest mark completion

Pytest mark completion suggests known pytest markers in pytest.mark contexts.

How to use it

Invoke completion after pytest.mark. in a test file.

import pytest

@pytest.mark.<caret>
def test_example():
    ...

Where the markers come from

  • Pytest's built-in markers, such as skip, skipif, xfail, parametrize, and usefixtures.
  • Markers registered in your project configuration under markers = ... in pyproject.toml, pytest.ini, or setup.cfg.
  • Markers contributed by installed pytest plugins, taken from BetterPy's pytest collection snapshot.

Built-in and configured markers are suggested immediately, without waiting for a pytest collection run. Each lookup entry shows the marker description and, for plugin markers, the contributing plugin.

The same marker knowledge also drives go-to-declaration and rename for a marker name, a gutter icon on marker declarations, quick documentation for marker usages, and the Unknown pytest marker in strict mode inspection.

Notes

  • Completion is offered only in real marker positions. import pytest, import pytest as pt, and from pytest import mark are recognised; unrelated decorators and a local object named pytest are ignored.
  • The feature is gated by the Pytest mark completion setting.