Comments (2)
Digging deeper into this matter, it looks like the steps are handled differently inside VSCODE and when run on the commandline.
When running the above snippet in VSCODE an extra yield at the top works fine although the steps are enumerated in random order in the drop down menu of VSCODE. I extended the test case from the documentation:
Starting the test case in VSCODE, they are started like this without the first yield
> ./.venv/bin/python -m pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=/var/folders/pt/zw8ycd8x1pl7w13s9ltgrvlc0000gq/T/tmp-361377bjf1ByIrKIL.xml ./tests/integration/apis/test_user_files.py::test_suite[4.step_d] cwd: .
I.e. one line per step, repeated In the order d,e,b,a,c.
And fails with:
´./tests/integration/apis/test_user_files.py::test_suite[3.step_c] Failed: [undefined]pytest_steps.steps_generator.StepYieldError: Error collecting results from step '3.step_c': received '1.step_a' from the yield
statement, which is different from the current step or step name. Please either use yield
, yield '3.step_c'
or wrap your step with with optional_step(...) as my_step:
and use yield my_step
´
Running the same test case from the command line with ´pytest´ works fine though.
This is actually a huge problem for us using VSCODE and a CI/CD pipeline. Any suggestions or ideas are more than welcome!
from python-pytest-steps.
Hi @danielFlemstrom, thanks for reporting !
It seems indeed very much related to VSCode...
Proably the best and fastest workaround is to get rid of pytest steps and instead passing a session-scoped fixture to all of your "steps" tests. You can then further use a basic test class to wrap the various "step" tests, if you want to have them nicely separated from others.
That's the easiest workaround I would suggest, not requiring strong investigations on how VSCode inspects pytest (which I do not have the bandwidth to perform as of now unfortunately)
I hope this helps!
from python-pytest-steps.
Related Issues (20)
- `@cross_steps_fixture` does not wait for the last step to perform teardown
- `pytest_harvest` should not be mandatory for install
- Plugin fails to be detected when pytest-harvest is not present
- When calling a decorated test function manually, the test step list is not taken into account HOT 1
- If a step that is not the first is selected by a '-k' keyword selection in pytest, no error is raised and the wrong step is run
- pytest-steps is not compatible with async functions (pytest.mark.asyncio) HOT 4
- Protect against python 2 unicode literals
- Replace `@with_signature(new_sig)` with stub files (`*.pyi`)
- Python 3.8 incompatibility: DeprecationWarning: collections.abc HOT 1
- Improve packaging
- TypeError: test_suite() missing 2 required positional arguments: '________step_name_' and 'request' HOT 15
- TypeError: Unable to hash test parameter '...'. Hashable parameters are required to use steps reliably. HOT 1
- Pytest marks on generator test step? HOT 2
- order inverted HOT 3
- pandas deprecation warning in steps_pytest_harvest_utils.py HOT 7
- Migrate project template to new one using github actions
- pytest-harvest + pytest-steps: results_bag fixture is cross-step, how to get per-step? HOT 5
- 1.8.0: pytest is failing HOT 13
- received StopIteration if yield not present. yeah? but what should i do inside an exception block HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-pytest-steps.