Skip to content

Commit 673bddc

Browse files
Test gherkin-terminal-reporter incompatibility usage errors
Cover both pytest.UsageError paths: another terminal reporter in use, and xdist enabled.
1 parent c352767 commit 673bddc

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎tests/feature/test_gherkin_terminal_reporter.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,33 @@ def _():
353353
result.stdout.fnmatch_lines("*Scenario: Scenario 2*")
354354
result.stdout.fnmatch_lines("*Rule: Rule 2*")
355355
result.stdout.fnmatch_lines("*Example: Example 3*")
356+
357+
358+
def test_other_terminal_reporter_is_not_compatible(pytester):
359+
pytester.makeconftest(
360+
textwrap.dedent(
361+
"""\
362+
from _pytest.terminal import TerminalReporter
363+
364+
365+
class AppleReporter(TerminalReporter):
366+
pass
367+
368+
369+
def pytest_plugin_registered(plugin):
370+
if type(plugin) is TerminalReporter:
371+
plugin.__class__ = AppleReporter
372+
"""
373+
)
374+
)
375+
pytester.makepyfile("def test_apple(): pass")
376+
result = pytester.runpytest("--gherkin-terminal-reporter")
377+
assert result.ret == pytest.ExitCode.USAGE_ERROR
378+
result.stderr.fnmatch_lines("*gherkin-terminal-reporter is not compatible with any other terminal reporter.*")
379+
380+
381+
def test_xdist_is_not_compatible(pytester):
382+
pytester.makepyfile("def test_apple(): pass")
383+
result = pytester.runpytest("--gherkin-terminal-reporter", "-p", "xdist", "-n", "1")
384+
assert result.ret == pytest.ExitCode.USAGE_ERROR
385+
result.stderr.fnmatch_lines("*gherkin-terminal-reporter is not compatible with 'xdist' plugin.")

0 commit comments

Comments
 (0)