jrnl-org / jrnl

Collect your thoughts and notes without leaving the command line.
https://jrnl.sh
GNU General Public License v3.0
6.51k stars 529 forks source link

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

Closed micahellison closed 7 months ago

micahellison commented 7 months ago

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

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 commented 7 months ago

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 commented 7 months ago

https://github.com/pytest-dev/pytest-bdd/issues/684

musicinmybrain commented 7 months ago

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 commented 7 months ago

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