Skip to content

pytest --fixtures drops indentation from fixture docstring #2574

Closed
@doerwalter

Description

@doerwalter

When a fixture docstring has varying levels of indentation pytest --fixtures drops the indentation completely. For example:

import pytest

@pytest.fixture(scope="module")
def foo(request):
   """
   Use the foo to foo the foo like this::

      foo("foo")
   """

calling python -mpytest test_foo.py --fixtures outputs:

================= test session starts ======================
...
------------ fixtures defined from test_foo ----------------
foo
    Use the foo to foo the foo like this::

    foo("foo")
=============== no tests ran in 0.03 seconds ===============

However I would have expected this to output:

================= test session starts ======================
...
------------ fixtures defined from test_foo ----------------
foo
    Use the foo to foo the foo like this::

       foo("foo")
=============== no tests ran in 0.03 seconds ===============

i.e. only the smallest indentation level should be stripped away (except maybe for the first line that requires special treatment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortopic: fixturesanything involving fixtures directly or indirectlytopic: reportingrelated to terminal output and user-facing messages and errors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions