Skip to content
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

Tags support for Example sections #413

Closed
wants to merge 3 commits into from

Conversation

elchupanebrej
Copy link

@elchupanebrej elchupanebrej commented Apr 6, 2021

This covers #411

  • Example tags could be used for test selection
  • Example tags could not be used for invoking pytest_bdd_apply_tag hook for now
  • Add explicit support for multiple Examples sections
  • "Examples: Vertical" replaced with "Examples Transposed:" for more convenient naming
  • Examples sections names are parsed (not used now)

@codecov
Copy link

codecov bot commented Apr 6, 2021

Codecov Report

Merging #413 (f250ea6) into master (0f02d56) will increase coverage by 0.61%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #413      +/-   ##
==========================================
+ Coverage   96.00%   96.62%   +0.61%     
==========================================
  Files          50       50              
  Lines        1679     1748      +69     
  Branches      159      166       +7     
==========================================
+ Hits         1612     1689      +77     
+ Misses         39       32       -7     
+ Partials       28       27       -1     
Impacted Files Coverage Δ
tests/feature/test_outline_empty_values.py 100.00% <ø> (ø)
pytest_bdd/reporting.py 85.50% <76.47%> (-0.65%) ⬇️
pytest_bdd/parser.py 100.00% <100.00%> (+0.44%) ⬆️
pytest_bdd/scenario.py 93.06% <100.00%> (+0.51%) ⬆️
pytest_bdd/types.py 100.00% <100.00%> (ø)
pytest_bdd/utils.py 100.00% <100.00%> (ø)
tests/feature/test_outline.py 100.00% <100.00%> (ø)
tests/feature/test_report.py 100.00% <100.00%> (+16.21%) ⬆️
tests/feature/test_tags.py 100.00% <100.00%> (ø)
pytest_bdd/hooks.py 100.00% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f02d56...f250ea6. Read the comment docs.

@elchupanebrej elchupanebrej marked this pull request as draft April 6, 2021 08:36
@elchupanebrej elchupanebrej force-pushed the examples_tags branch 5 times, most recently from 06bfb00 to dc55288 Compare April 6, 2021 11:48
@elchupanebrej elchupanebrej marked this pull request as ready for review April 6, 2021 12:49
@felipesetti
Copy link

felipesetti commented May 20, 2021

Hi, this is a really helpful feature! What is the status of this issue?

@diogormendes
Copy link

Indeed, this is a very expected feature !! +1

@KelvinKSPS
Copy link

It is a very expected feature!
Is there anything pending we can help?

@elchupanebrej
Copy link
Author

pytest_bdd requires original parser to be rewritten. This PR uses and extends old parser, so seems that this PR won't be accepted till work on new parser would be finished(and has to be re-done after)

I'm in progress of development fork of pytest_bdd which uses cucumber.io gherkin parser, which will support this feature from the box (essential for project which I test), but won't get support of code generation and maybe other features of pytest_bdd on start. I think it could take few weeks to show this feature, because I'm busy on my main project

elchupanebrej and others added 2 commits May 26, 2021 19:24
- Example tags could be used for test selection
- Example tags could not be used for invoking pytest_bdd_apply_tag hook for now
- Add explicit support for multiple Examples sections
- "Examples: Vertical" replaced with "Examples Transposed:" for more convenient naming
- Examples sections names are parsed (not used now)
@elchupanebrej
Copy link
Author

Also, this feature aggravate #296 #310

@@ -267,12 +288,20 @@ def params(self):

def get_example_params(self):
"""Get example parameter names."""
return set(self.examples.example_params + self.feature.examples.example_params)
return set(
chain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{examples.example_params for examples in chain(...)}?

return [self.example_params, params]
else:
return []
self.examples = list(zip(*self.example_param_values))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks weird. why does it assign to self in get_() function instead of return?

for param_names in scenario_param_data.keys():
parametrize_values = []
for param_tags, param_values in scenario_param_data[param_names]:
marks = list(map(partial(getattr, pytest.mark), param_tags))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marks = [...]


decorator_chain.append(pytest.mark.parametrize(list(param_names), parametrize_values))

compose = lambda *func: reduce(lambda f, g: lambda x: f(g(x)), func, lambda x: x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay.. let's not turn python into haskell

@@ -496,13 +496,13 @@ pytest-bdd feature file format also supports example tables in different way:
When I eat <eat> cucumbers
Then I should have <left> cucumbers

Examples: Vertical
Examples Transposed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to separate tags from transposed examples into separate PRs? It is very hard to follow what's what

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elchupanebrej
Copy link
Author

This will be reopened after #475 merge

@elchupanebrej elchupanebrej deleted the examples_tags branch April 2, 2022 11:45
@CuriousQA
Copy link

Hey,

I see this is waiting for #475, but the other issue is closed now and the branch is deleted. Kindly suggest when would this be available or if there exists any alternatives.

Regards,

@elchupanebrej
Copy link
Author

@CuriousQA seems, that this feature (and many others attached to it) won't be implemented in this project, because of internal problems that must be unwrapped at first. The biggest one is a rewriting parser of Gherkin files. This activity seems ongoing, so I decided to make a fork of this project, to have the possibility to implement essential features which I need personally.

That fork supports tags for example sections but doesn't support vertical examples (because they are not a part of the "standard"). You could find it here https://github.com/elchupanebrej/pytest-bdd-ng

@CuriousQA
Copy link

Thank you @elchupanebrej for your response. I will look into the link you shared it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants