Use compatibility function to assert outcomes

This commit is contained in:
Alessio Bogon 2020-09-05 19:05:57 +02:00
parent 29c8c69424
commit 0408218680
4 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,7 @@
"""Scenario Outline tests."""
import textwrap
from tests.utils import assert_outcomes
STEPS = """\
from pytest_bdd import given, when, then
@ -111,7 +112,7 @@ def test_wrongly_outlined(testdir):
)
)
result = testdir.runpytest()
result.assert_outcomes(error=1)
assert_outcomes(result, errors=1)
result.stdout.fnmatch_lines(
'*ScenarioExamplesNotValidError: Scenario "Outlined with wrong examples"*has not valid examples*',
)
@ -151,7 +152,7 @@ def test_wrong_vertical_examples_scenario(testdir):
)
)
result = testdir.runpytest()
result.assert_outcomes(error=1)
assert_outcomes(result, errors=1)
result.stdout.fnmatch_lines(
"*Scenario has not valid examples. Example rows should contain unique parameters. "
'"start" appeared more than once.*'
@ -192,7 +193,7 @@ def test_wrong_vertical_examples_feature(testdir):
)
)
result = testdir.runpytest()
result.assert_outcomes(error=1)
assert_outcomes(result, errors=1)
result.stdout.fnmatch_lines(
"*Feature has not valid examples. Example rows should contain unique parameters. "
'"start" appeared more than once.*'

View File

@ -2,6 +2,8 @@
import textwrap
from tests.utils import assert_outcomes
def test_scenario_not_found(testdir):
"""Test the situation when scenario is not found."""
@ -30,7 +32,7 @@ def test_scenario_not_found(testdir):
)
result = testdir.runpytest()
result.assert_outcomes(error=1)
assert_outcomes(result, errors=1)
result.stdout.fnmatch_lines('*Scenario "NOT FOUND" in feature "Scenario is not found" in*')

View File

@ -2,6 +2,8 @@
import textwrap
from tests.utils import assert_outcomes
def test_multiple_features_single_file(testdir):
"""Test validation error when multiple features are placed in a single file."""
@ -49,5 +51,5 @@ def test_multiple_features_single_file(testdir):
)
)
result = testdir.runpytest()
result.assert_outcomes(error=1)
assert_outcomes(result, errors=1)
result.stdout.fnmatch_lines("*FeatureError: Multiple features are not allowed in a single feature file.*")

View File

@ -3,6 +3,7 @@ import itertools
import textwrap
from pytest_bdd.scenario import get_python_name_generator
from tests.utils import assert_outcomes
def test_python_name_generator():
@ -60,7 +61,7 @@ def test_generate_missing(testdir):
)
result = testdir.runpytest("--generate-missing", "--feature", "generation.feature")
result.assert_outcomes(passed=0, failed=0, error=0)
assert_outcomes(result, passed=0, failed=0, errors=0)
assert not result.stderr.str()
assert result.ret == 0