Use compatibility function to assert outcomes
This commit is contained in:
parent
29c8c69424
commit
0408218680
|
@ -1,6 +1,7 @@
|
||||||
"""Scenario Outline tests."""
|
"""Scenario Outline tests."""
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from tests.utils import assert_outcomes
|
||||||
|
|
||||||
STEPS = """\
|
STEPS = """\
|
||||||
from pytest_bdd import given, when, then
|
from pytest_bdd import given, when, then
|
||||||
|
@ -111,7 +112,7 @@ def test_wrongly_outlined(testdir):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.assert_outcomes(error=1)
|
assert_outcomes(result, errors=1)
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
'*ScenarioExamplesNotValidError: Scenario "Outlined with wrong examples"*has not valid examples*',
|
'*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 = testdir.runpytest()
|
||||||
result.assert_outcomes(error=1)
|
assert_outcomes(result, errors=1)
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
"*Scenario has not valid examples. Example rows should contain unique parameters. "
|
"*Scenario has not valid examples. Example rows should contain unique parameters. "
|
||||||
'"start" appeared more than once.*'
|
'"start" appeared more than once.*'
|
||||||
|
@ -192,7 +193,7 @@ def test_wrong_vertical_examples_feature(testdir):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.assert_outcomes(error=1)
|
assert_outcomes(result, errors=1)
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
"*Feature has not valid examples. Example rows should contain unique parameters. "
|
"*Feature has not valid examples. Example rows should contain unique parameters. "
|
||||||
'"start" appeared more than once.*'
|
'"start" appeared more than once.*'
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from tests.utils import assert_outcomes
|
||||||
|
|
||||||
|
|
||||||
def test_scenario_not_found(testdir):
|
def test_scenario_not_found(testdir):
|
||||||
"""Test the situation when scenario is not found."""
|
"""Test the situation when scenario is not found."""
|
||||||
|
@ -30,7 +32,7 @@ def test_scenario_not_found(testdir):
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
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*')
|
result.stdout.fnmatch_lines('*Scenario "NOT FOUND" in feature "Scenario is not found" in*')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
from tests.utils import assert_outcomes
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_features_single_file(testdir):
|
def test_multiple_features_single_file(testdir):
|
||||||
"""Test validation error when multiple features are placed in a single file."""
|
"""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 = 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.*")
|
result.stdout.fnmatch_lines("*FeatureError: Multiple features are not allowed in a single feature file.*")
|
||||||
|
|
|
@ -3,6 +3,7 @@ import itertools
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from pytest_bdd.scenario import get_python_name_generator
|
from pytest_bdd.scenario import get_python_name_generator
|
||||||
|
from tests.utils import assert_outcomes
|
||||||
|
|
||||||
|
|
||||||
def test_python_name_generator():
|
def test_python_name_generator():
|
||||||
|
@ -60,7 +61,7 @@ def test_generate_missing(testdir):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = testdir.runpytest("--generate-missing", "--feature", "generation.feature")
|
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 not result.stderr.str()
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue