Closed
Description
Here's a ~minimal example:
# pytest_foo/__init__.py
import pytest
@pytest.fixture
def special_asserter():
def f(x, y):
assert x == y
return f
# conftest.py
pytest_plugins = ['pytest_foo']
# t.py
def test(special_asserter):
special_asserter(1, 2)
$ python -m pytest -p pytest_foo t.py
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.6.2, py-1.8.0, pluggy-0.12.0
rootdir: /tmp/x
collected 1 item
t.py F [100%]
=================================== FAILURES ===================================
_____________________________________ test _____________________________________
special_asserter = <function special_asserter.<locals>.f at 0x7f54d53c5ea0>
def test(special_asserter):
> special_asserter(1, 2)
t.py:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = 1, y = 2
def f(x, y):
> assert x == y
E AssertionError
pytest_foo/__init__.py:7: AssertionError
=========================== 1 failed in 0.02 seconds ===========================
Expected:
$ python -m pytest t.py
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.6.2, py-1.8.0, pluggy-0.12.0
rootdir: /tmp/x
collected 1 item
t.py F [100%]
=================================== FAILURES ===================================
_____________________________________ test _____________________________________
special_asserter = <function special_asserter.<locals>.f at 0x7fdf0c1a7d90>
def test(special_asserter):
> special_asserter(1, 2)
t.py:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = 1, y = 2
def f(x, y):
> assert x == y
E assert 1 == 2
pytest_foo/__init__.py:7: AssertionError
=========================== 1 failed in 0.02 seconds ===========================