Fixes #271: Use parametrize markers params for getting example_kwargs#272
Fixes #271: Use parametrize markers params for getting example_kwargs#272sliwinski-milosz wants to merge 12 commits intopytest-dev:masterfrom
Conversation
|
Please before merging, let me add similar test as in fix of unicode steps (but to do that easily unicode steps fix needs to be merged) |
|
I added test and I made test function bit more generic. However I still think that it would be good to firstly merge the fix for CI tests :) |
|
Please note that "work in progress" label can be removed. This pull request is ready for review. |
tests/utils.py
Outdated
| return os.path.splitext(filename)[0] | ||
|
|
||
|
|
||
| def prepare_feature_and_py_files(testdir, feature_file, py_file): |
There was a problem hiding this comment.
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 test_scenario_in_expanded_mode test manage the resources (and let the test be in the pytest-bdd style, not a normal test)
There was a problem hiding this comment.
I will rewrite it to pytest-bdd style.
I added prepare_feature_and_py_files to be able to reuse feature files that are already in other tests, to test them in expanded mode.
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.
Tests have been rewritten to pytest-bdd style.
tests/feature/parametrized.feature
Outdated
| Then I should have <left> cucumbers | ||
|
|
||
|
|
||
| Scenario: Parametrized given - single param |
There was a problem hiding this comment.
what is this test asserting? There is no "then" step
There was a problem hiding this comment.
You already have asked that question :). Shall we add comment somewhere in the code explaining what this test is testing?
|
|
||
| ghe = test_execution['gherkin'] | ||
| ghe.assert_outcomes(passed=1) | ||
| result.assert_outcomes(passed=1) |
There was a problem hiding this comment.
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.
The problem that this pull request fixes is that expanded gherkin report was crashing while reporting test_parametrized test.
So this assertion just checks if test was able to run or if there was a crash.
…le_parameter_name
|
I think this PR is also ready for review :) |
User can parametrize scenario by using examples specified in feature files. In that case pytest
parametrizemarker is updated with examples parameters.We also provide a way to parametrize scenario on the python side by using
pytest.mark.parametrize. https://pytest-bdd.readthedocs.io/en/latest/#combine-scenario-outline-and-pytest-parametrizationThe problem with gherkin reporting is that when we are getting
self.example_kwargs, we are usingscenario.get_example_params()method that takes into account only args that are defined inside feature file (examples), and skipspytest.mark.parametrizeparameters.For gherkin reporting we need all parameters: those specified in feature files and those specified by using
pytest.mark.parametrizedecorator.This pull requests uses
parametrizemarker to get all args.