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

Fixtures not overriden in directories with similar names #2948

Closed
lincis opened this issue Nov 24, 2017 · 1 comment
Closed

Fixtures not overriden in directories with similar names #2948

lincis opened this issue Nov 24, 2017 · 1 comment

Comments

@lincis
Copy link

lincis commented Nov 24, 2017

When fixtures with the same name are defined in neighboring directories with similar names (e.g. aaa and aaa1 as in example below) fixture from only one of the directories is invoked.

I have repeated this with pytest-2.7 and pytest-3.2 on with both python2 and python3 on various Linux OSs.

Consider the following directory/file tree:
pytest
├── aaa
│   ├── conftest.py
│   └── test_fixa.py
├── aaa1
│   ├── conftest.py
│   └── test_fix1.py
├── aaa2
│   ├── conftest.py
│   └── test_fix.py
└── aaaa
├── conftest.py
└── test_fixaa.py

Each conftest.py defines fixture fix, as

import pytest
import os
dir_path = os.path.dirname(os.path.realpath(__file__))

@pytest.fixture()
def fix():
        print (dir_path)

and tests defined as

def test_fix(fix):
        assert 1

When the tests are run the following output is generated:

$ pytest -vs .
========================================================================== test session starts ==========================================================================
platform linux2 -- Python 2.7.13, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 -- /usr/bin/python2
cachedir: .cache
rootdir: /home/linards/tests/python, inifile:
collected 4 items

pytest/aaa/test_fixa.py::test_2 /home/***/tests/python/pytest/aaa
PASSED
pytest/aaa1/test_fix1.py::test_2 /home/***/tests/python/pytest/aaa
PASSED
pytest/aaa2/test_fix.py::test_2 /home/***/tests/python/pytest/aaa
PASSED
pytest/aaaa/test_fixaa.py::test_2 /home/***/tests/python/pytest/aaaa
PASSED
@RonnyPfannschmidt
Copy link
Member

RonnyPfannschmidt commented Nov 24, 2017

this is a duplicate of #2836 which ws fixed in #2862 - please try with a more recent pytest - i believe the fix is included since 3.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants