From 9a69a6ecfc1dbd2313e35413f74840d8a6a06f7d Mon Sep 17 00:00:00 2001 From: Alessio Bogon <778703+youtux@users.noreply.github.com> Date: Sat, 28 Sep 2024 18:28:50 +0200 Subject: [PATCH] Drop compatibility with pytest < 7 --- CHANGES.rst | 1 + pyproject.toml | 2 +- src/pytest_bdd/utils.py | 2 +- tests/generation/test_generate_missing.py | 2 +- tests/scripts/test_generate.py | 4 ++-- tox.ini | 3 +-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f0511332..d1ca8b7d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,7 @@ Changelog Unreleased ---------- +- Drop compatibility with pytest < 7.0.0. 8.0.0b1 ---------- diff --git a/pyproject.toml b/pyproject.toml index 1fe4f635..f04c1766 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ python = ">=3.8" Mako = "*" parse = "*" parse-type = "*" -pytest = ">=6.2.0" +pytest = ">=7.0.0" typing-extensions = "*" packaging = "*" gherkin-official = "^29.0.0" diff --git a/src/pytest_bdd/utils.py b/src/pytest_bdd/utils.py index 34263f7e..b08ce88c 100644 --- a/src/pytest_bdd/utils.py +++ b/src/pytest_bdd/utils.py @@ -71,7 +71,7 @@ def collect_dumped_objects(result: RunResult) -> list: Note: You must run the result with output to stdout enabled. For example, using ``pytester.runpytest("-s")``. """ - stdout = result.stdout.str() # pytest < 6.2, otherwise we could just do str(result.stdout) + stdout = str(result.stdout) payloads = re.findall(rf"{_DUMP_START}(.*?){_DUMP_END}", stdout) return [pickle.loads(base64.b64decode(payload)) for payload in payloads] diff --git a/tests/generation/test_generate_missing.py b/tests/generation/test_generate_missing.py index d6be9be6..f2a9ac3e 100644 --- a/tests/generation/test_generate_missing.py +++ b/tests/generation/test_generate_missing.py @@ -137,7 +137,7 @@ def _(param): assert not result.stderr.str() assert result.ret == 0 - output = result.stdout.str() + output = str(result.stdout) assert "I use the string parser" not in output assert "I use parsers.parse" not in output diff --git a/tests/scripts/test_generate.py b/tests/scripts/test_generate.py index 98f9a10f..fcb97909 100644 --- a/tests/scripts/test_generate.py +++ b/tests/scripts/test_generate.py @@ -100,7 +100,7 @@ def test_generate_with_quotes(pytester): ) result = pytester.run("pytest-bdd", "generate", "generate_with_quotes.feature") - assert result.stdout.str() == textwrap.dedent( + assert str(result.stdout) == textwrap.dedent( '''\ """Handling quotes in code generation feature tests.""" @@ -211,4 +211,4 @@ def _(): raise NotImplementedError ''' ) - assert result.stdout.str() == expected_output + assert str(result.stdout) == expected_output diff --git a/tox.ini b/tox.ini index 718d3019..8954258b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] distshare = {homedir}/.tox/distshare -envlist = py{3.8,3.9,3.10,3.11}-pytest{6.2,7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3,latest}-coverage +envlist = py{3.8,3.9,3.10,3.11}-pytest{7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3,latest}-coverage py{3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest}-coverage py3.12-pytestlatest-xdist-coverage mypy @@ -19,7 +19,6 @@ deps = pytest7.2: pytest~=7.2.0 pytest7.1: pytest~=7.1.0 pytest7.0: pytest~=7.0.0 - pytest6.2: pytest~=6.2.0 coverage: coverage[toml] xdist: pytest-xdist