Skip to content

Commit 4fc39bb

Browse files
committed
adds test to assist
1 parent 2c234c0 commit 4fc39bb

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

services/web/server/requirements/_test.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ jsonschema
2222
openapi-spec-validator
2323
pytest
2424
pytest-aiohttp
25+
# ----
2526
# Overcomes "Known issues" in https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.23.8
2627
# IMPORTANT: This constraint can be removed when `test_pytest_asyncio_known_issue` passes with the new update of pytest-asyncio
2728
pytest-asyncio<0.23
29+
# ----
2830
pytest-benchmark
2931
pytest-cov
3032
pytest-docker
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
5+
import asyncio
6+
7+
import pytest
8+
import pytest_asyncio
9+
10+
pytest_simcore_core_services_selection = [
11+
"migration",
12+
"postgres",
13+
]
14+
pytest_simcore_ops_services_selection = []
15+
16+
17+
@pytest.fixture(autouse=True)
18+
def _drop_and_recreate_postgres(database_from_template_before_each_function: None):
19+
return
20+
21+
22+
@pytest.fixture
23+
def some_fixture(
24+
event_loop: asyncio.AbstractEventLoop,
25+
simcore_services_ready: None,
26+
):
27+
event_loop.run_until_complete(asyncio.sleep(0.1))
28+
29+
30+
# NOTE: Remove skip marker to check whether `pytest-asyncio<0.23` constraint in _test.in
31+
@pytest.mark.skip(reason="Checks pytest-asyncio upgrade issue")
32+
async def test_pytest_asyncio_known_issue(some_fixture: None):
33+
#
34+
# This test demonstrates a common failure in most integration tests when using pytest-asyncio version 0.23.
35+
# The test was derived by simplifying the original test_garbage_collection.py to highlight the issue.
36+
#
37+
# Due to an unresolved issue in pytest-asyncio, pytest will fail to execute this async test,
38+
# resulting in the following error:
39+
#
40+
# `RuntimeError: There is no current event loop in thread 'MainThread'.`
41+
#
42+
# For more details, refer to the "Known Issues" section in the release notes:
43+
# https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.23.8
44+
#
45+
46+
assert pytest_asyncio.__version__
47+
48+
# NOTE: it might fail upon db tear-down but it is not relevant for this test

0 commit comments

Comments
 (0)