-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #271: Use parametrize markers params for getting example_kwargs #272
base: master
Are you sure you want to change the base?
Changes from 8 commits
8cbcab6
e016791
ca0efed
b3c0e3f
646fc1c
432e0e0
645a9f2
df1f21e
8fef144
cd4d74a
256f6c6
0646548
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import os | ||
import re | ||
|
||
|
||
import pytest | ||
|
||
from pytest_bdd import scenario, given, when, then | ||
from pytest_bdd import given, scenario, then, when | ||
from tests.utils import get_test_filepath, prepare_feature_and_py_files | ||
|
||
|
||
|
@@ -349,18 +349,18 @@ def output_output_must_contain_parameters_values(test_execution, gherkin_scenari | |
|
||
@pytest.mark.parametrize( | ||
'feature_file, py_file, name', [ | ||
('./steps/unicode.feature', './steps/test_unicode.py', 'test_steps_in_feature_file_have_unicode') | ||
('./steps/unicode.feature', './steps/test_unicode.py', 'test_steps_in_feature_file_have_unicode'), | ||
('./feature/parametrized.feature', './feature/test_parametrized.py', 'test_parametrized') | ||
] | ||
) | ||
def test_scenario_in_expanded_mode(testdir, test_execution, feature_file, py_file, name): | ||
def test_scenario_in_expanded_mode(testdir, feature_file, py_file, name): | ||
prepare_feature_and_py_files(testdir, feature_file, py_file) | ||
|
||
test_execution['gherkin'] = testdir.runpytest( | ||
'-k %s' % name, | ||
py_filename = os.path.basename(py_file) | ||
result = testdir.runpytest( | ||
'%s::%s' % (py_filename, name), | ||
'--gherkin-terminal-reporter', | ||
'--gherkin-terminal-reporter-expanded', | ||
'-vv', | ||
) | ||
|
||
ghe = test_execution['gherkin'] | ||
ghe.assert_outcomes(passed=1) | ||
result.assert_outcomes(passed=1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are asserting that the test pass, but not the behaviour of the terminal report, which is the whole point of this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem that this pull request fixes is that expanded gherkin report was crashing while reporting |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,22 @@ def get_test_filepath(filepath): | |
return os.path.join(curr_file_dirpath, filepath) | ||
|
||
|
||
def get_filename_without_ext(path): | ||
filename = os.path.basename(path) | ||
return os.path.splitext(filename)[0] | ||
|
||
|
||
def prepare_feature_and_py_files(testdir, feature_file, py_file): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function was used only once, and it's implementation was tied to the caller. I would say to remove it and let the caller There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will rewrite it to pytest-bdd style. I added I will remove it, and I'll create separate tests for gherkin reporter. That means that we may have some duplication but it is safer approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests have been rewritten to pytest-bdd style. |
||
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) | ||
feature_filename = get_filename_without_ext(feature_file.name) | ||
kwargs = {feature_filename: feature_content} | ||
testdir.makefile('.feature', **kwargs) | ||
|
||
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) | ||
py_filename = get_filename_without_ext(py_file.name) | ||
kwargs = {py_filename: py_content} | ||
testdir.makepyfile(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this test asserting? There is no "then" step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have asked that question :). Shall we add comment somewhere in the code explaining what this test is testing?
#272 (comment)