pytest-dev / pytest-dev/pytest

short test summary: different formats for skip, xfail and xpass

Open
#5,077 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Thanks for submitting an issue!

Here's a quick checklist in what to include:

  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • pytest and operating system versions
  • Minimal example if possible

In the report printed by pytest -ra, skip, xfail and xpass messages are formatted slightly differently from one another.

Python 3.7 / Arch Linux

$ pip list
Package        Version
-------------- -------
atomicwrites   1.3.0  
attrs          19.1.0 
more-itertools 7.0.0  
pip            19.0.3 
pluggy         0.9.0  
py             1.8.0  
pytest         4.4.0  
setuptools     40.8.0 
six            1.12.0
$ cat test_foo.py
import pytest

@pytest.mark.skip(reason="world")
def test_skip(): assert False

@pytest.mark.xfail(reason="hello")
def test_hello(): pass

@pytest.mark.xfail(reason="world")
def test_world(): assert False
$ pytest -ra
===================================== test session starts ======================================
platform linux -- Python 3.7.3, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: /tmp/foo
collected 3 items                                                                              

test_foo.py sXx                                                                          [100%]
=================================== short test summary info ====================================
SKIPPED [1] test_foo.py:3: world
XFAIL test_foo.py::test_world
  world
XPASS test_foo.py::test_hello hello

======================= 1 skipped, 1 xfailed, 1 xpassed in 0.02 seconds ========================

Notice that the skip message is the only one to include the line number and the xfail message the only one to be prepended with a newline.

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

Reproduce the report with the test_foo.py example and run pytest -ra to inspect the short test summary. Compare the skip, xfail, and xpass output, then make their formatting consistent and verify the updated summary with the same example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.