Comments (3)
Unlike what I thought, it appears that the event loop isn't running inside finalizers. That means that my task would indeed never have been executed.
Consequently, this achieves what I was looking for:
@pytest.fixture
def foo_fixture(request, event_loop):
def fin():
async def afin():
await some_stuff()
event_loop.run_until_complete(afin())
request.addfinalizer(fin)
return 42
I let you choose to close this issue or not. My point of view is that it would at least deserve a proper documentation. Better API would be nice to have, but since it's py35 only use-case, I don't really see the point, finally.
I can submit a documentation PR for this if you will. Let me know.
from pytest-asyncio.
My 2c: just document it.
IMO 3.6 asyncio is way better than 3.5 and we (as a community) should steer new developers to 3.6.
from pytest-asyncio.
@dimaqq Thanks! Can't agree more. The point is that LTS versions of some well-known Linux distros won't get support for py36 unless using third-party packages. So I'll just stick to 3.5 until next LTS.
from pytest-asyncio.
Related Issues (20)
- Support for Pytest 8.0 HOT 14
- pytest-asyncio makes pytest collect modules not matching `python_files`, causing `ModuleNotFoundError` HOT 3
- Startup failure on Windows with Version 0.23.3 HOT 1
- 0.23.3 breaking ImportError exception HOT 1
- documentation on how to force all tests in one session to use the same event loop appears to not force fixtures into the same event loop HOT 4
- TypeError: __call__() got an unexpected keyword argument 'specname' in version 0.23 pytest-asyncio HOT 3
- Python 3.11: DeprecationWarning: There is no current event loop HOT 12
- Hypothesis integration raises internal error when collecting `RuleBasedStateMachine` HOT 2
- AsyncGenerator early exit doesn't raise CancelledError and doesn't run `finally` branch HOT 4
- RuntimeError: "Timeout context manager should be used inside a task" in aiohttp with version 0.23 pytest-asyncio HOT 1
- pytest 8.0.0 AttributeError: 'Package' object has no attribute 'obj' HOT 2
- AttributeError: '_UnixSelectorEventLoop' object has no attribute '_compute_internal_coro' HOT 1
- Drop support for pytest 7
- Factory fixtures are causing `'Coroutine' object is not callable` warning in UI, but tests still run HOT 3
- Configuration option for default loop scope
- Can't async mock a method in a context manager HOT 2
- Parametrizing `event_loop_policy` parametrizes all tests
- Not compatible with --doctest-modules --doctest-ignore-import-errors HOT 1
- How to use event_loop_policy without triggering warnings? HOT 1
- "The test […] is not an async function" when `asyncio` marker is added via `pytest_collection_modifyitems()` HOT 1
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 pytest-asyncio.