Skip to content

Conversation

felixonmars
Copy link
Contributor

Pytest 4 removed support for calling fixtures directly: https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly

This leads to an error when trying to run the tests:

==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_bounding_box.py __________________
Fixture "red" called directly. Fixtures are not meant to be called directly,
but are created automatically when test functions request them as parameters.
See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.

Pytest 4 removed support for calling fixtures directly: https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly

This leads to an error when trying to run the tests:
```
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_bounding_box.py __________________
Fixture "red" called directly. Fixtures are not meant to be called directly,
but are created automatically when test functions request them as parameters.
See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.
```
@felixonmars
Copy link
Contributor Author

The test failure looks irrelevant.

@Hanaasagi
Copy link
Contributor

It seems to be caused by setuptools.

Ref: pypa/setuptools#1257

@mcepl
Copy link

mcepl commented Nov 1, 2019

Thank you! Works for on openSUSE/Tumbleweed (and it is a part of the official package now).

Copy link
Contributor

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to do this



@pytest.fixture
def red():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def red():
@pytest.fixture
def red():
"""Create an FST object for testing."""
return construct_fst()
def construct_fst()
"""Return an FST object."""

return red()


fst = red()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fst = red()
fst = construct_fst()

vibbix pushed a commit to kayak/redbaron that referenced this pull request Mar 26, 2020
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

Successfully merging this pull request may close these issues.

4 participants