I would like my tests to report only top failed function. Is there any pytest-specific functions/hooks to rewrite to get needed result?
Below is test example:
#!/usr/bin/env pytest
import pytest
def sub_function():
pytest.fail("This will fail here")
def test_1():
sub_function()
The output I'm getting is the following:
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.2, pytest-4.4.1, py-1.7.0, pluggy-0.9.0
rootdir: /home/ashot/questions
collected 1 item
test_file.py F [100%]
==================================================================== FAILURES ====================================================================
_____________________________________________________________________ test_1 _____________________________________________________________________
def test_1():
> sub_function()
test_file.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def sub_function():
> pytest.fail("This will fail here")
E Failed: This will fail here
test_file.py:6: Failed
============================================================ 1 failed in 0.12 seconds ============================================================
While I would like to get something like:
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.2, pytest-4.4.1, py-1.7.0, pluggy-0.9.0
rootdir: /home/ashot/questions
collected 1 item
test_file.py F [100%]
==================================================================== FAILURES ====================================================================
_____________________________________________________________________ test_1 _____________________________________________________________________
def test_1():
> sub_function()
E Failed: This will fail here
test_file.py:9: Failed
============================================================ 1 failed in 0.12 seconds ============================================================
Aucun commentaire:
Enregistrer un commentaire