Skip to content

Package fixture doesn't respect dependency #7400

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

Closed
voronind opened this issue Jun 22, 2020 · 2 comments
Closed

Package fixture doesn't respect dependency #7400

voronind opened this issue Jun 22, 2020 · 2 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly type: bug problem that needs to be addressed

Comments

@voronind
Copy link

  1. Package fixture doesn't tear down after dir "exiting".
  2. Package fixture doesn't use another package fixture depends on it. See comment in pytest output.

Ubuntu 20.04, pytest==5.4.3, python 3.6

expr/
    test1/
        conftest.py
        test_1.py
    test2/
        conftest.py
        test_2.py
    conftest.py

expr/test1/conftest.py

from pytest import fixture

@fixture('package')
def company():
    print('\ncompany == 1')
    yield 1
    print('\ncompany == 1 tear down')

expr/test1/test_1.py

def test_1(company2):
    assert company2 == 1

expr/test2 is same but 2 instead of 1

expr/conftest.py

from pytest import fixture

@fixture('package')
def company2(company):
    print('\ncompany2 == ', company)
    yield company
    print('\ncompany2 == ', company, ' tear down')

Ouput:

================ test session starts ====================
platform linux -- Python 3.6.9, pytest-5.4.3, py-1.7.0, pluggy-0.13.1
rootdir: /home/voronin/projects/sintez_addons, inifile: setup.cfg
collected 2 items                                                                                                                                                                                                                            

expr/test_1/test_1.py 
company == 1

company2 ==  1
PASSED
expr/test_2/test_2.py 
# <- Why there is no company == 1 tear down. Why company2 doesn't use company==2?
company == 2
FAILED           
company2 ==  1  tear down

company == 2 tear down

company == 1 tear down


============ FAILURES ==================
___________________ test_2 ________________

company2 = 1

    def test_2(company2):
>       assert company2 == 2
E       assert 1 == 2

expr/test_2/test_2.py:3: AssertionError
========== short test summary info =======================
FAILED expr/test_2/test_2.py::test_2 - assert 1 == 2
=========== 1 failed, 1 passed in 0.08s ======================
@voronind
Copy link
Author

#7232
#4684

@Zac-HD Zac-HD added topic: fixtures anything involving fixtures directly or indirectly type: bug problem that needs to be addressed labels Jun 22, 2020
@bluetech
Copy link
Member

bluetech commented Jan 4, 2024

I believe this should be fixed with #11646. Please test pip install pytest==8.0.0rc1 and let us know if not!

@bluetech bluetech closed this as completed Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants