Skip to content

Commit

Permalink
Change loop fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Nov 14, 2022
1 parent 52a7f97 commit 5bcc09e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/tribler/core/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import os
import os
import sys
Expand Down Expand Up @@ -231,19 +232,9 @@ def test_tdef(state_dir):
return tdef


@pytest.fixture
def loop(event_loop):
"""
_This_ fixture masks the original "loop" fixture from pytest-asyncio,
effectively replacing it with the "event_loop" fixture from aiohttp.
It solves the following problem:
pytest-asyncio provides "loop" fixture for creating the event loop,
aiohttp provides "event_loop" fixture for creating the event loop,
if you use the "@pytest.mark.asyncio" decorator on a test, it will automatically run the "loop"
fixture, which could result in test failure if the test uses Futures created with the fixtures
that use the "event_loop" fixture.
"""
return event_loop
@pytest.fixture()
def loop():
return asyncio.get_event_loop()


@pytest.fixture
Expand Down

0 comments on commit 5bcc09e

Please sign in to comment.