pytest-bdd
pytest-bdd copied to clipboard
support async scenarios
Support async scenarios without requiring any specific async framework
Codecov Report
Merging #426 (702a1e8) into master (c7faa9f) will increase coverage by
0.22%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #426 +/- ##
==========================================
+ Coverage 96.14% 96.36% +0.22%
==========================================
Files 50 51 +1
Lines 1684 1731 +47
Branches 159 163 +4
==========================================
+ Hits 1619 1668 +49
+ Misses 38 37 -1
+ Partials 27 26 -1
| Impacted Files | Coverage Δ | |
|---|---|---|
| pytest_bdd/__init__.py | 100.00% <100.00%> (ø) |
|
| pytest_bdd/scenario.py | 98.34% <100.00%> (+5.79%) |
:arrow_up: |
| tests/feature/test_async_scenarios.py | 100.00% <100.00%> (ø) |
|
| tests/utils.py | 66.66% <0.00%> (-33.34%) |
:arrow_down: |
| tests/conftest.py | 77.77% <0.00%> (-22.23%) |
:arrow_down: |
| tests/feature/test_tags.py | 96.15% <0.00%> (-3.85%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update c7faa9f...702a1e8. Read the comment docs.
I'm sorry, but I'm not a big fan of this approach. Specifically, I don't like having a program that produces code, I find it hard to debug and to reason about.
I would instead try a different approach using a library like greenletio.
It would be ideal if we can keep the sync version of the code as it is (or at least with as few modifications as possible), and instead provide only the async version of the main functions (async_scenario, async_scenarios).
This is the same approach that SQLAlchemy took when introducing compatibility with asyncio, and it seem to have worked out well.
greenletio is specific for asyncio, whereas I'm looking for support for Trio
I also see another library, https://greenback.readthedocs.io/, but I didn't have time to check it properly.
Using green threads seems like it would be harder to debug rather than easier.
Would using unasync like a linter be better? As in it just fails CI if the awaits have not been removed by the developer correctly from the sync version of the code?
This would also help with getting the coverage to pass
A note from the greenback docs:
Should I trust this in production? Maybe; try it and see. The technique is in some ways an awful hack
@youtux looking at those green utilities I worked out I could make my own await_ function