pytest-assume
pytest-assume copied to clipboard
Failed assumption plus error in setup causes subsequent test to appear to fail
If a fixture has an assumption failure and an error, then the assumption failure is not cleared, and it will look like the subsequent test failed with that assumption failure.
I am working on a fix and will have a PR soon.
To reproduce, use the following pytest code:
import pytest
@pytest.fixture
def fix():
pytest.assume(5 == 6, "I live in assume.py::fix fixture")
raise Exception('oops in setup')
def test_assume(fix):
pytest.assume(3 == 4, "I live in assume.py::test_assume")
def test_assume3():
pass
Result is that both tests appear to fail. test_assume
fails with the Exception, and test_assume3
fails with test_assume
's failed assumption:
pytest test_assume_example.py
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-5.3.4, py-1.8.0, pluggy-0.13.0
rootdir: /vagrant/git/dcs_tests/pytest
plugins: assume-2.2.0
collected 2 items
test_assume_example.py EF [100%]
==================================== ERRORS ====================================
________________________ ERROR at setup of test_assume _________________________
@pytest.fixture
def fix():
pytest.assume(5 == 6, "I live in assume.py::fix fixture")
> raise Exception('oops in setup')
E Exception: oops in setup
test_assume_example.py:5: Exception
=================================== FAILURES ===================================
_________________________________ test_assume3 _________________________________
tp = <class 'pytest_assume.plugin.FailedAssumption'>, value = None, tb = None
def reraise(tp, value, tb=None):
try:
if value is None:
value = tp()
if value.__traceback__ is not tb:
> raise value.with_traceback(tb)
E pytest_assume.plugin.FailedAssumption:
E 1 Failed Assumptions:
E
E test_assume_example.py:4: AssumptionFailure
E >> pytest.assume(5 == 6, "I live in assume.py::fix fixture")
E AssertionError: I live in assume.py::fix fixture
E assert False
/usr/local/lib/python3.6/dist-packages/six.py:692: FailedAssumption
========================== 1 failed, 1 error in 0.27s ==========================
Thanks for the report & PR! I'll get around to reviewing it shortly.
Thanks, Ashley!