Skip to content

Commit b6e3de9

Browse files
authored
Merge branch 'master' into scenario-outline-with-slashes
2 parents 849cf34 + 30ffbe2 commit b6e3de9

File tree

8 files changed

+92
-8
lines changed

8 files changed

+92
-8
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Changelog
33

44
Unreleased
55
----------
6+
- Drop compatibility with pytest < 7.0.0.
67

78
8.0.0b1
89
----------

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ python = ">=3.8"
3939
Mako = "*"
4040
parse = "*"
4141
parse-type = "*"
42-
pytest = ">=6.2.0"
42+
pytest = ">=7.0.0"
4343
typing-extensions = "*"
4444
packaging = "*"
4545
gherkin-official = "^29.0.0"

src/pytest_bdd/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def collect_dumped_objects(result: RunResult) -> list:
7171
Note: You must run the result with output to stdout enabled.
7272
For example, using ``pytester.runpytest("-s")``.
7373
"""
74-
stdout = result.stdout.str() # pytest < 6.2, otherwise we could just do str(result.stdout)
74+
stdout = str(result.stdout)
7575
payloads = re.findall(rf"{_DUMP_START}(.*?){_DUMP_END}", stdout)
7676
return [pickle.loads(base64.b64decode(payload)) for payload in payloads]
7777

tests/feature/test_steps.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,51 @@ def _(stuff):
622622
)
623623

624624

625+
def test_lower_case_and(pytester):
626+
pytester.makefile(
627+
".feature",
628+
steps=textwrap.dedent(
629+
"""\
630+
Feature: Step keywords need to be capitalised
631+
632+
Scenario: Step keywords must be capitalised
633+
Given that I'm writing an example
634+
and that I like the lowercase 'and'
635+
Then it should fail to parse
636+
"""
637+
),
638+
)
639+
pytester.makepyfile(
640+
textwrap.dedent(
641+
"""\
642+
import pytest
643+
from pytest_bdd import given, when, then, scenarios
644+
645+
scenarios("steps.feature")
646+
647+
648+
@given("that I'm writing an example")
649+
def _():
650+
pass
651+
652+
653+
@given("that I like the lowercase 'and'")
654+
def _():
655+
pass
656+
657+
658+
@then("it should fail to parse")
659+
def _():
660+
pass
661+
662+
"""
663+
)
664+
)
665+
result = pytester.runpytest()
666+
result.assert_outcomes(errors=1)
667+
result.stdout.fnmatch_lines("*TokenError*")
668+
669+
625670
def test_right_aligned_steps(pytester):
626671
"""Parser correctly handles steps that are not left-aligned"""
627672
pytester.makefile(
@@ -653,3 +698,42 @@ def _():
653698
)
654699
result = pytester.runpytest()
655700
result.assert_outcomes(passed=1, failed=0)
701+
702+
703+
def test_keywords_used_outside_steps(pytester):
704+
"""Correctly identify when keyword is used for steps and when it's used for other cases."""
705+
pytester.makefile(
706+
".feature",
707+
keywords="""\
708+
Feature: Given this is a Description
709+
710+
In order to achieve something
711+
I want something
712+
Because it will be cool
713+
Given it is valid description
714+
When it starts working
715+
Then I will be happy
716+
717+
718+
Some description goes here.
719+
720+
Scenario: When I set a Description
721+
Given I have a bar
722+
""",
723+
)
724+
pytester.makepyfile(
725+
textwrap.dedent(
726+
"""\
727+
from pytest_bdd import given, scenarios
728+
729+
scenarios("keywords.feature")
730+
731+
@given("I have a bar")
732+
def _():
733+
pass
734+
735+
"""
736+
)
737+
)
738+
result = pytester.runpytest()
739+
result.assert_outcomes(passed=1, failed=0)

tests/generation/test_generate_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _(param):
137137
assert not result.stderr.str()
138138
assert result.ret == 0
139139

140-
output = result.stdout.str()
140+
output = str(result.stdout)
141141

142142
assert "I use the string parser" not in output
143143
assert "I use parsers.parse" not in output

tests/scripts/test_generate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_generate_with_quotes(pytester):
100100
)
101101

102102
result = pytester.run("pytest-bdd", "generate", "generate_with_quotes.feature")
103-
assert result.stdout.str() == textwrap.dedent(
103+
assert str(result.stdout) == textwrap.dedent(
104104
'''\
105105
"""Handling quotes in code generation feature tests."""
106106
@@ -211,4 +211,4 @@ def _():
211211
raise NotImplementedError
212212
'''
213213
)
214-
assert result.stdout.str() == expected_output
214+
assert str(result.stdout) == expected_output

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
distshare = {homedir}/.tox/distshare
3-
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
3+
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
44
py{3.12,3.13}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,latest}-coverage
55
py3.12-pytestlatest-xdist-coverage
66
mypy
@@ -19,7 +19,6 @@ deps =
1919
pytest7.2: pytest~=7.2.0
2020
pytest7.1: pytest~=7.1.0
2121
pytest7.0: pytest~=7.0.0
22-
pytest6.2: pytest~=6.2.0
2322

2423
coverage: coverage[toml]
2524
xdist: pytest-xdist

0 commit comments

Comments
 (0)