Skip to main content

Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.

Project description

pytest-spec

Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.
[Documentation]

Available features

  • Format output to look like specification.
  • Group tests by classes and files
  • Failed, passed and skipped are marked and colored.
  • Remove test_ and underscores for every test.
  • It is possible to use docstring summary instead of test name.
  • Supports function based, class based test.
  • Supports describe like tests.

Output example

Example

Configuration

spec_header_format

spec_header_format

You can configure the format of the test headers by specifying a format string in your ini-file:

    ; since pytest 4.6.x
    [pytest]
    spec_header_format = {module_path}:

    ; legacy pytest
    [tool:pytest]
    spec_header_format = {module_path}:

or in your pyproject.toml file:

    [tool.pytest.ini_options]
    spec_header_format = "{module_path}:"

In addition to the {path} and {class_name} replacement fields, there is also {test_case} that holds a more human readable name.

spec_test_format

spec_test_format

You can configure the format of the test results by specifying a format string in your ini-file:

3 variables are available:

  • result - place for indicator
  • name - name of test
  • docstring_summary - first line from test docstring if available
    ; since pytest 4.6.x
    [pytest]
    spec_test_format = {result} {name}

    ; legacy pytest
    [tool:pytest]
    spec_test_format = {result} {name}

or

    ; since pytest 4.6.x
    [pytest]
    spec_test_format = {result} {docstring_summary}

    ; legacy pytest
    [tool:pytest]
    spec_test_format = {result} {docstring_summary}

In second example where docstring is not available the name will be added to spec output.

Similar configuration could be done in your pyproject.toml file:

    [tool.pytest.ini_options]
    spec_test_format = "{result} {name}"

or

    [tool.pytest.ini_options]
    spec_test_format = "{result} {docstring_summary}"
spec_success_indicator

spec_success_indicator

You can configure the indicator displayed when test passed.

ini-file

    ; since pytest 4.6.x
    [pytest]
    spec_success_indicator = 

    ; legacy pytest
    [tool:pytest]
    spec_success_indicator = 

or pyproject.toml

    [tool.pytest.ini_options]
    spec_success_indicator = "✓"
spec_failure_indicator

spec_failure_indicator

You can configure the indicator displated when test failed.

ini-file

    ; since pytest 4.6.x
    [pytest]
    spec_failure_indicator = 

    ; legacy pytest
    [tool:pytest]
    spec_failure_indicator = 

or pyproject.toml

    [tool.pytest.ini_options]
    spec_failure_indicator = "✗"
spec_skipped_indicator

spec_skipped_indicator

You can configure the indicator displated when test is skipped.

ini-file

    ; since pytest 4.6.x
    [pytest]
    spec_skipped_indicator = »

    ; legacy pytest
    [tool:pytest]
    spec_skipped_indicator = »

or pyproject.toml

    [tool.pytest.ini_options]
    spec_skipped_indicator = "»"
spec_ignore

spec_ignore

Comma-separated settings to ignore/hide some tests or output from from plugins like FLAKE8 or ISORT. Any test which contain provided string will be ignored in output spec.

ini-file

    ; since pytest 4.6.x
    [pytest]
    spec_ignore = FLAKE8

    ; legacy pytest
    [tool:pytest]
    spec_ignore = FLAKE8

or pyproject.toml

    [tool.pytest.ini_options]
    spec_ignore = "FLAKE8"
spec_indent

spec_indent

ini-file

    ; since pytest 4.6.x
    [pytest]
    spec_indent = "   "

    ; legacy pytest
    [tool:pytest]
    spec_indent = "   "

or pyproject.toml

    [tool.pytest.ini_options]
    spec_indent = "   "

Continuous Integration

Tests

Download

All versions of library are available on official pypi server.

Install

From pypi.org

    pip install pytest-spec

From source

    cd pytest-spec
    uv sync

From source for testing

    cd pytest-spec
    uv sync --all-extras --dev

From source for build or deployment

    cd pytest-spec
    uv sync
    uv build
    uv publish

Contribution

Please feel free to present your idea by code example (pull request) or reported issues.

Contributors

License

pytest-spec - pytest plugin to display test execution output like a SPECIFICATION.

Copyright (C) 2014-2025 Pawel Chomicki

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_spec-5.1.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

pytest_spec-5.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_spec-5.1.0.tar.gz.

File metadata

  • Download URL: pytest_spec-5.1.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_spec-5.1.0.tar.gz
Algorithm Hash digest
SHA256 841aef3d40b1be61351ade0b1bd8de25d74530670c55f4f95de8c6ebf3ea10cd
MD5 ac895488deb261fc9b6bda48dc5d41ea
BLAKE2b-256 3e1c5e03ff220b4ef73fb07eb525a2bbf5d804d73bf291e1cdc0ed1f2450f1db

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_spec-5.1.0.tar.gz:

Publisher: release.yml on pchomik/pytest-spec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_spec-5.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_spec-5.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_spec-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 363594b7d63421caf48e4ec6f4caa6d764fac1f56186c9d200173bc97f28fcab
MD5 f6de29da77337ac4c28e4a7518dae4ff
BLAKE2b-256 0ab46832aa168573cce23f0177a94281b24324915d718dcd0b7685383f9c2c9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_spec-5.1.0-py3-none-any.whl:

Publisher: release.yml on pchomik/pytest-spec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page