Update pytest-bdd to v8.0 (#1955)

* Encapsulate all multiline strings in triple-quotes in Gherkin files

Since pytest-bdd v8.0.0 uses the official Gherkin parser, multiline
strings must now be encapsulated by triple-quotes.

See:
- https://pytest-bdd.readthedocs.io/en/stable/#id2
- https://pytest-bdd.readthedocs.io/en/stable/#docstrings

* Remove comments in Gherkin files causing test breakage

These comments break the step matching.

* Fix compatibility of step-functions matching on multiple lines

In pytest-bdd v8.0.0 it is no longer possible to match based on multiple
lines, which breaks essentially all steps that support docstrings. Solve
this by adding a wrapper-function for each of these instances, that
matches the docstring step, and calls the original function.

So, what used to be:

    @then(parse("the output should match\n{regex}"))
    @then(parse('the output should match "{regex}"'))
    def output_should_match(regex, cli_run):
        ...

Is now:

    @then(parse("the output should match"))
    def output_should_match_docstring(cli_run, docstring):
        output_should_match(docstring, cli_run)

    @then(parse('the output should match "{regex}"'))
    def output_should_match(regex, cli_run):
        ...

There is possibly a way around this that is much better than what I've
done here, but this is a start at least.

* Update version requirement of pytest-bdd to >=8.0

* Update tox config to match poetry config

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Carl Smedstad 2025-02-25 05:16:54 +01:00 committed by GitHub
parent 505a9b6846
commit 1530ad39a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 451 additions and 67 deletions

26
poetry.lock generated
View file

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.
[[package]]
name = "asttokens"
@ -444,6 +444,17 @@ docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.
testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"]
typing = ["typing-extensions (>=4.12.2)"]
[[package]]
name = "gherkin-official"
version = "29.0.0"
description = "Gherkin parser (official, by Cucumber team)"
optional = false
python-versions = "*"
files = [
{file = "gherkin_official-29.0.0-py3-none-any.whl", hash = "sha256:26967b0d537a302119066742669e0e8b663e632769330be675457ae993e1d1bc"},
{file = "gherkin_official-29.0.0.tar.gz", hash = "sha256:dbea32561158f02280d7579d179b019160d072ce083197625e2f80a6776bb9eb"},
]
[[package]]
name = "ghp-import"
version = "2.1.0"
@ -1204,21 +1215,22 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no
[[package]]
name = "pytest-bdd"
version = "7.3.0"
version = "8.0.0"
description = "BDD for pytest"
optional = false
python-versions = ">=3.8"
python-versions = ">=3.9"
files = [
{file = "pytest_bdd-7.3.0-py3-none-any.whl", hash = "sha256:168ede4a118e348feb70182590ee4a2f856e68dafe54a75a4e9203da37d4ade6"},
{file = "pytest_bdd-7.3.0.tar.gz", hash = "sha256:9dfeb1d8565d9548907f36a5a9e2c8e1e0cbac3b2724e17331b87386a19fbc16"},
{file = "pytest_bdd-8.0.0-py3-none-any.whl", hash = "sha256:a62f52c8e4198824ce7fa6ddb8b419565466c15727469647899dc2c626d959d7"},
{file = "pytest_bdd-8.0.0.tar.gz", hash = "sha256:f520c6f307cca7d4a8b0141394eed4f0873ba82124b161a26af0bb7cba20fca9"},
]
[package.dependencies]
gherkin-official = ">=29.0.0,<30.0.0"
Mako = "*"
packaging = "*"
parse = "*"
parse-type = "*"
pytest = ">=6.2.0"
pytest = ">=7.0.0"
typing-extensions = "*"
[[package]]
@ -1780,4 +1792,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.10.0, <3.14"
content-hash = "b1d7129a811405c5cb82fed2ace5529a830b1a373a7929557aa6ac22058b950b"
content-hash = "ef6226bf4ee37a69297a2c21ab95539525ba604cfb7d7b2d715bddcb5724f672"