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

Fix tests under pytest 4 #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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

@@ -8,7 +8,6 @@
from redbaron import RedBaron


@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."""

def red_fixture():
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 added 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