Skip to content

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

Description

@micahellison

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.

Activity

  1. added
    testIssues related to tests we need to add
    bugSomething isn't working
    and removed on Mar 24, 2024
  2. 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[/+] on Mar 24, 2024
  3. micahellison commented on Mar 24, 2024

    @micahellison
    MemberAuthor

    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.

  4. musicinmybrain commented on Mar 27, 2024

    @musicinmybrain
    Contributor
  5. musicinmybrain commented on Mar 27, 2024

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

  6. musicinmybrain commented on Mar 27, 2024

    @musicinmybrain
    Contributor

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

  7. added 2 commits that reference this issue on Mar 28, 2024
    71c9ffa
    384977c
  8. added a commit that references this issue on Mar 28, 2024
    48b61f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtestIssues related to tests we need to add

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions