Comments (8)
We are seeing this too, combinations tested that failed to behave as expected:
- pytest 8.1.2, pytest-bdd 7.1.2
- pytest 8.2.0, pytest-bdd 7.1.2
Downgrading to pytest 7.4.4 fixes it.
from pytest-bdd.
I created the PR
from pytest-bdd.
We have this problem too (pytest==8.2.2
and pytest-bdd==7.2.0
).
The PR by @dcendents fixes it 👍.
from pytest-bdd.
I don't have time to open a pull request right now, will try to eventually but this seems to work (I modified the file locally in my venv and executed my BDD tests and they all pass with pytest-bdd 7.1.2 and pytest 8.2.0).
Changes between releases 7.0.1 and 7.1.2: 7.0.1...7.1.2
file src/pytest_bdd/compat.py
has been added with two methods to register a fixture, one for pytest 8.1+ and one for older pytest version.
I simply copied the inject_fixture
function from pytest < 8.1 and adapted the arguments to create the FixtureDef
with the correct arguments since pytest 8.1 and left the rest as is and it seems to work:
def inject_fixture(request: FixtureRequest, arg: str, value: Any) -> None:
"""Inject fixture into pytest fixture request.
:param request: pytest fixture request
:param arg: argument name
:param value: argument value
"""
fd = FixtureDef(
config=request._fixturemanager.config,
baseid=request.node.nodeid,
argname=arg,
func=lambda: value,
scope="function",
params=None,
ids=None,
_ispytest=True,
)
fd.cached_result = (value, 0, None)
old_fd = request._fixture_defs.get(arg)
add_fixturename = arg not in request.fixturenames
def fin() -> None:
request._fixturemanager._arg2fixturedefs[arg].remove(fd)
if old_fd is not None:
request._fixture_defs[arg] = old_fd
if add_fixturename:
request._pyfuncitem._fixtureinfo.names_closure.remove(arg)
request.addfinalizer(fin)
# inject fixture definition
request._fixturemanager._arg2fixturedefs.setdefault(arg, []).append(fd)
# inject fixture value in request cache
request._fixture_defs[arg] = fd
if add_fixturename:
request._pyfuncitem._fixtureinfo.names_closure.append(arg)
If someone wants to open a PR and make sure it doesn't break anything please feel free to do so. Otherwise I'll get to it eventually...
Cheers,
from pytest-bdd.
We are having the same issue, and the PR looks blocked, any updates on when this fix will be available?
from pytest-bdd.
I can confirm that the issue exists in combination with pytest v8 but not with pytest v7.
from pytest-bdd.
Related Issues (20)
- `iterparentnodeids` removed from pytest HOT 1
- Step definition parses wrong parameter from feature file
- Unable to run parallel tests with pytest-xdist - can't serialize <class 'pytest_bdd.parser.Step'> HOT 1
- Pytest emits deprecation warning: "A private pytest class or function was used" HOT 3
- pytest-bdd doesn't support pytest 8.1.0 HOT 5
- Missing git tags for 7.1 and 7.1.1 releases HOT 1
- Python 3.8/pytest 3.0.4/pytest-bdd 3.1.0 crash: TypeError: an integer is required (got type bytes) HOT 2
- Pytest 8.1.1 fixture injection compability HOT 2
- Unable to run pytest-bdd with pytest-xdist, can't serialize <class 'pytest_bdd.parser.Step'> HOT 4
- Does pytest-bdd support pytest-xdist? HOT 2
- Version 7.1.2 no longer provides pytest_bdd.steps.inject_fixture HOT 1
- Issue with existing working automation after python 3.11.1 and pytest-bdd 7.00 upgrade HOT 6
- Re-use of target_fixture not possible anymore HOT 2
- How to apply for function/module/package/session scope to feature HOT 2
- Is there a hook for 'before_feature' in pytest-bdd? HOT 2
- Stacking multiple `then` decorators breaks parametrization HOT 2
- Document data tables
- multiple test files are triggered by single feature file HOT 3
- Custom fixture unable to inherit target_fixtures HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-bdd.