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

Tests failing on develop branch starting with pytest-bdd 7.1.2 #1875

Closed
micahellison opened this issue Mar 24, 2024 · 4 comments · Fixed by #1878
Closed

Tests failing on develop branch starting with pytest-bdd 7.1.2 #1875

micahellison opened this issue Mar 24, 2024 · 4 comments · Fixed by #1878
Labels
bug Something isn't working test Issues related to tests we need to add

Comments

@micahellison
Copy link
Member

micahellison commented Mar 24, 2024

Diagnostic output

n/a

Current Behavior

Around a week ago, pytest-bdd 7.1.2 was released and all of our PRs started failing tests with this error on tests/lib/when_steps.py:

ImportError: Error importing plugin "tests.lib.when_steps": cannot import name 'inject_fixture' from 'pytest_bdd.steps'

Expected Behavior

Tests should be running fine. This patch release of pytest-bdd is a breaking change for us, though.

Repro Steps

  • Open pyproject.toml, pin pytest-bdd version: pytest-bdd = "7.1.1"
  • Run poetry install and poetry run pytest. Everything passes.
  • Open pyproject.toml, pin pytest-bdd version: pytest-bdd = "7.1.2"
  • Run poetry install and poetry run pytest. Everything fails.

Debug output

n/a

Other Information

I don't have a lot of time to look at this now, and am tempted to pin pytest to 7.1.1 for now just to be able to get through PRs, though if a contributor has a fix for this, it would be welcome.

@micahellison micahellison added 🆕 New! test Issues related to tests we need to add labels Mar 24, 2024
@micahellison micahellison added bug Something isn't working and removed 🆕 New! labels Mar 24, 2024
@micahellison micahellison changed the title Tests failing on develop branch starting with pytest 7.1.2 Tests failing on develop branch starting with pytest-bdd 7.1.2 Mar 24, 2024
@micahellison
Copy link
Member Author

It looks like version pinning is a bit trickier than I'd thought, I think due to irregularities between how poetry and tox handle pytest plugin versions. Probably better to spend time on just fixing the root cause.

@musicinmybrain
Copy link
Contributor

@musicinmybrain
Copy link
Contributor

The immediate workaround would be something like:

try:
    from pytest_bdd.compat import inject_fixture  # since pytest_bdd 7.1.2
except ImportError:
    from pytest_bdd.steps import inject_fixture  # before pytest_bdd 7.1.2

but perhaps it would be worth considering, in the medium term, whether there is an alternative to using an unsupported function that could move again or disappear.

@musicinmybrain
Copy link
Contributor

Alternatively, I guess you could just from pytest_bdd.compat import inject_fixture and update to pytest_bdd>=7.1.2.

musicinmybrain added a commit to musicinmybrain/jrnl that referenced this issue Mar 28, 2024
musicinmybrain added a commit to musicinmybrain/jrnl that referenced this issue Mar 28, 2024
micahellison added a commit that referenced this issue Mar 28, 2024
* Support pytest_bdd 7.1.2 and later

Fix #1875.

* Prevent use of pytest 8.1 for now due to unrelated error

* poetry lock --no-update

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working test Issues related to tests we need to add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants