Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does pytest.skip('Output string') get printed?

Tags:

python

I have the following code in a python module called test_me.py:

@pytest.fixture()
def test_me():
     if condition:
        pytest.skip('Test Message')

def test_func(test_me):
    assert ...

The output looks like:

tests/folder/test_me.py::test_me SKIPPED

Question: Where does 'Test Message' get printed or output? I can't see or find it anywhere.

like image 946
Parazyne Avatar asked Oct 26 '25 04:10

Parazyne


1 Answers

According to the Pytest documentation, you can use the -rs flag to show it.

$ pytest -rs
======================== test session starts ========================
platform darwin -- Python 3.7.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: ...
collected 1 item                                                    

test_sample.py s                                              [100%]

====================== short test summary info ======================
SKIPPED [1] test_sample.py:5: Test Message
======================== 1 skipped in 0.02s =========================
import pytest

@pytest.fixture()
def test_me():
   pytest.skip('Test Message')

def test_1(test_me):
   pass

Not sure if this is platform-specific, or if it works with OPs configuration, since OP didn't provide any specific info.

like image 146
ATOMP Avatar answered Oct 28 '25 20:10

ATOMP