Skip to content

Commit

Permalink
Merge branch 'master' into gherkin_reporter_parametrized_tests_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sliwinski-milosz authored Dec 19, 2018
2 parents ca0efed + fb44fc3 commit b3c0e3f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pytest_bdd/gherkin_terminal_reporter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-

from __future__ import unicode_literals

import re

from _pytest.terminal import TerminalReporter
Expand Down
20 changes: 20 additions & 0 deletions tests/feature/test_gherkin_terminal_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from pytest_bdd import scenario, given, when, then
from tests.utils import get_test_filepath, prepare_feature_and_py_files


@scenario('gherkin_terminal_reporter.feature',
Expand Down Expand Up @@ -344,3 +345,22 @@ def output_output_must_contain_parameters_values(test_execution, gherkin_scenari
ghe.stdout.fnmatch_lines('*When I eat {eat} cucumbers'.format(**gherkin_scenario_outline))
ghe.stdout.fnmatch_lines('*Then I should have {left} cucumbers'.format(**gherkin_scenario_outline))
ghe.stdout.fnmatch_lines('*PASSED')


@pytest.mark.parametrize(
'feature_file, py_file, name', [
('./steps/unicode.feature', './steps/test_unicode.py', 'test_steps_in_feature_file_have_unicode')
]
)
def test_scenario_in_expanded_mode(testdir, test_execution, feature_file, py_file, name):
prepare_feature_and_py_files(testdir, feature_file, py_file)

test_execution['gherkin'] = testdir.runpytest(
'-k %s' % name,
'--gherkin-terminal-reporter',
'--gherkin-terminal-reporter-expanded',
'-vv',
)

ghe = test_execution['gherkin']
ghe.assert_outcomes(passed=1)
18 changes: 18 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os


def get_test_filepath(filepath):
curr_file_dirpath = os.path.dirname(os.path.realpath(__file__))
return os.path.join(curr_file_dirpath, filepath)


def prepare_feature_and_py_files(testdir, feature_file, py_file):
feature_filepath = get_test_filepath(feature_file)
with open(feature_filepath) as feature_file:
feature_content = feature_file.read()
testdir.makefile('.feature', unicode=feature_content)

py_filepath = get_test_filepath(py_file)
with open(py_filepath) as py_file:
py_content = py_file.read()
testdir.makepyfile(test_gherkin=py_content)

0 comments on commit b3c0e3f

Please sign in to comment.