Skip to content

Fixture is not overriden in the child conftest.py when running individual test file #294

Closed
@pytestbot

Description

@pytestbot

Originally reported by: Oleg Pidsadnyi (BitBucket: olegp, GitHub: olegp)


If I have the package with the conftest.py:

#!python

from pytest import fixture

@fixture
def foo():
    return 'parent'

And I have subfolder with the conftest.py:

#!python

from pytest import fixture

@fixture
def foo():
    return 'child'

And the test_foo.py in the same subfolder:

#!python

def test_foo(foo):
    assert foo == 'child'

It works when I simply run py.test in the parent folder.

It doesn't work when I run py.test subfolder/test_foo.py

For some reason the value is 'parent', not 'child'


Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions