New issue 476: Fixtures defined in separate files are not available to tests
https://bitbucket.org/hpk42/pytest/issue/476/fixtures-defined-in-separate-files-are-not
Jimmy Cuadra:
Given the following files in a package:
```
#!ini
# setup.cfg
[pytest]
python_files = *_test.py *_fixture.py
```
```
#!python
# mypackage/tests/fixtures/foo_fixture.py
from pytest import fixture
@fixture
def my_fixture():
return 'stub'
```
```
#!python
# mypackage/tests/lib/foo_test.py
def test_foo(my_fixture):
assert my_fixture == 'stub'
```
Running `py.test` results in:
```
file mypackage/tests/lib/foo_test.py
@wraps(func)
def patched(*args, **keywargs):
fixture 'my_fixture' not found
available fixtures: pytestconfig, recwarn, monkeypatch, capfd, capsys,
tmpdir
use 'py.test --fixtures [testpath]' for help on them.
```
I can confirm that collection is working properly, because I can raise an
exception in `foo_fixture.py` and it shows up when running `py.test`. (I can
also add a test to the fixture file and it is discovered properly.)
Is this expected behavior? Why is the fixture not available to tests? I want to
load fixtures from their own files rather than inlining them in conftest.py.
Thank you!
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit