Conversation
I was playing with the tutorial at https://smarie.github.io/python-pytest-steps/#c-optional-steps-and-dependencies and got this error. I had indented badly and my code looked like this: with optional_step('step_b') as step_b: assert True yield step_b # should have been unindented, caused this error. I just wanted to help any other newbie get past this in case it happened to them.
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
=======================================
Coverage 83.52% 83.52%
=======================================
Files 27 27
Lines 1153 1153
=======================================
Hits 963 963
Misses 190 190
Continue to review full report at Codecov.
|
| if res.exec_result is None: | ||
| raise ValueError("Internal error: this should not happen") | ||
| raise ValueError("Internal error: this should not happen." | ||
| "Did you ``yield step_b`` inside the context manager instead of after it?") |
There was a problem hiding this comment.
Great suggestion. We just need to use the actual step name rather than "step_b", I guess this should do the trick, can you check ?
| "Did you ``yield step_b`` inside the context manager instead of after it?") | |
| "Did you ``yield %s`` inside the context manager instead of after it?" % optional_step.step_name) |
There was a problem hiding this comment.
At this time optional_step is an instance of type, so you need to read res.step_name instead.
| "Did you ``yield step_b`` inside the context manager instead of after it?") | |
| raise ValueError("Internal error: this should not happen.\n" | |
| "Did you ``yield %s`` inside the context manager instead of after it?" % res.step_name) |
Here is a case that reproduces the error, do you want me to turn it into a test or something?
from pytest_steps import test_steps, optional_step
@test_steps('step_a')
def test_suite_opt():
# Step A
with optional_step('step_a') as step_a:
assert True
yield step_a
By the way, your efforts at documentation, code clarity, and response to pull requests are all just exemplary. Thanks a lot for supporting this.
There was a problem hiding this comment.
oops thanks for catching my mistake, I edited your PR too fast. Of course your suggestion is the correct one.
Concerning the test: I actually hesitated to ask you this ! but since you're proposing, yes do not hesitate to add such a test, in a separate test file under test/ (and not test_raw/) folder.
But I can also do it once merged based on your example, so do not feel forced, up to you.
Oh and thanks so much for the kind words ! I really appreciate :)
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
=======================================
Coverage 83.52% 83.52%
=======================================
Files 27 27
Lines 1153 1153
=======================================
Hits 963 963
Misses 190 190 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I was playing with the tutorial at https://smarie.github.io/python-pytest-steps/#c-optional-steps-and-dependencies and got this error.
I had indented badly and my code looked like this:
with optional_step('step_b') as step_b:
assert True
yield step_b # should have been unindented, caused this error.
I just wanted to help any other newbie get past this in case it happened to them.