pytest-dev / pytest-dev/pytest

prioritize outputting relative paths in the terminal

Open
#12,973 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

What's the problem this feature will solve?
  1. Reduce the occurrence of identical path prefixes in the output.
  2. Minimize platform-dependent differences in output.
Describe the solution you'd like

Use Cases:

import pytest

@pytest.mark.skip("balabala")
def test_skip():
    pass


@pytest.mark.unknown_mark
def test_pass():
    pass


def test_fixture(miss_setup):
    print('hi there')

Execution:

pytest --junit-xml=junit.xml

Output: (Expected: Remove the absolute paths highlighted in green.)

terminal
(terminal)

junitxml
(junitxml)

Alternative Solutions

No configuration or plugin solution has been found yet.
Try to add a 'cwd_relative_path' method and call it before the output path to convert the absolute path to a relative path

Additional context

https://github.com/pytest-dev/pytest/discussions/12911

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown tests with pytest --junit-xml=junit.xml and compare the terminal and JUnit XML paths with the expected relative output. Trace where those two outputs format paths; done means the repeated absolute prefixes are removed consistently without a configuration or plugin.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.