Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion rewrite does not rewrite `__init__.py` in plugin packages (__init__.py) #5433

Closed
asottile opened this issue Jun 11, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@asottile
Copy link
Member

commented Jun 11, 2019

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 ===========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.