Update dependency pytest-asyncio to v1.2.0 (#492)

* Update dependency pytest-asyncio to v1.2.0

* don't stop the event loop between test

set the loop_scope to session for async tests

* remove loop_scope="session"

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Stefan Allius <stefan.allius@t-online.de>
This commit is contained in:
renovate[bot]
2025-09-15 22:50:47 +02:00
committed by GitHub
parent 45ab95a6b3
commit 2019037ab0
14 changed files with 181 additions and 181 deletions

View File

@@ -61,7 +61,7 @@ def create_inverter_client(config_conn):
return inv
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_home(client):
"""Test the home route."""
response = await client.get('/')
@@ -69,7 +69,7 @@ async def test_home(client):
assert response.mimetype == 'text/html'
assert b"<title>TSUN Proxy - Connections</title>" in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_page(client):
"""Test the mqtt page route."""
response = await client.get('/mqtt')
@@ -78,7 +78,7 @@ async def test_page(client):
assert b"<title>TSUN Proxy - MQTT Status</title>" in await response.data
assert b'fetch("/mqtt-fetch")' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_rel_page(client):
"""Test the mqtt route with relative paths."""
web.build_relative_urls = True
@@ -88,7 +88,7 @@ async def test_rel_page(client):
assert b'fetch("./mqtt-fetch")' in await response.data
web.build_relative_urls = False
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_notes(client):
"""Test the notes page route."""
response = await client.get('/notes')
@@ -96,7 +96,7 @@ async def test_notes(client):
assert response.mimetype == 'text/html'
assert b"<title>TSUN Proxy - Important Messages</title>" in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_logging(client):
"""Test the logging page route."""
response = await client.get('/logging')
@@ -104,42 +104,42 @@ async def test_logging(client):
assert response.mimetype == 'text/html'
assert b"<title>TSUN Proxy - Log Files</title>" in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_favicon96(client):
"""Test the favicon-96x96.png route."""
response = await client.get('/favicon-96x96.png')
assert response.status_code == 200
assert response.mimetype == 'image/png'
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_favicon(client):
"""Test the favicon.ico route."""
response = await client.get('/favicon.ico')
assert response.status_code == 200
assert response.mimetype == 'image/x-icon'
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_favicon_svg(client):
"""Test the favicon.svg route."""
response = await client.get('/favicon.svg')
assert response.status_code == 200
assert response.mimetype == 'image/svg+xml'
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_apple_touch_icon(client):
"""Test the apple-touch-icon.png route."""
response = await client.get('/apple-touch-icon.png')
assert response.status_code == 200
assert response.mimetype == 'image/png'
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_manifest(client):
"""Test the site.webmanifest route."""
response = await client.get('/site.webmanifest')
assert response.status_code == 200
assert response.mimetype == 'application/manifest+json'
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_data_fetch(client, create_inverter):
"""Test the data-fetch route."""
_ = create_inverter
@@ -150,7 +150,7 @@ async def test_data_fetch(client, create_inverter):
assert response.status_code == 200
assert b'<h5>Connections</h5>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_data_fetch1(client, create_inverter_server):
"""Test the data-fetch route with server connection."""
_ = create_inverter_server
@@ -161,7 +161,7 @@ async def test_data_fetch1(client, create_inverter_server):
assert response.status_code == 200
assert b'<h5>Connections</h5>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_data_fetch2(client, create_inverter_client):
"""Test the data-fetch route with client connection."""
_ = create_inverter_client
@@ -172,7 +172,7 @@ async def test_data_fetch2(client, create_inverter_client):
assert response.status_code == 200
assert b'<h5>Connections</h5>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_language_en(client):
"""Test the language/en route and cookie."""
response = await client.get('/language/en', headers={'referer': '/index'})
@@ -190,7 +190,7 @@ async def test_language_en(client):
assert b'<html lang="en"' in await response.data
assert b'<title>TSUN Proxy - Connections</title>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_language_de(client):
"""Test the language/de route."""
@@ -219,7 +219,7 @@ async def test_language_de(client):
assert b'<html lang=en>' in await response.data
assert b'<title>Redirecting...</title>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_language_unknown(client):
"""Test the language/unknown route."""
response = await client.get('/language/unknown')
@@ -233,7 +233,7 @@ async def test_language_unknown(client):
assert b'<title>TSUN Proxy - Connections</title>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_mqtt_fetch(client, create_inverter):
"""Test the mqtt-fetch route."""
_ = create_inverter
@@ -244,7 +244,7 @@ async def test_mqtt_fetch(client, create_inverter):
assert b'<h5>MQTT devices</h5>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_notes_fetch(client, config_conn):
"""Test the notes-fetch route."""
_ = config_conn
@@ -284,7 +284,7 @@ async def test_notes_fetch(client, config_conn):
assert b'config_err' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_file_fetch(client, config_conn, monkeypatch):
"""Test the data-fetch route."""
_ = config_conn
@@ -313,7 +313,7 @@ async def test_file_fetch(client, config_conn, monkeypatch):
assert response.status_code == 200
assert b'<h4>test.txt</h4>' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_send_file(client, config_conn):
"""Test the send-file route."""
_ = config_conn
@@ -323,7 +323,7 @@ async def test_send_file(client, config_conn):
assert b'2025-04-30 00:01:23' in await response.data
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_missing_send_file(client, config_conn):
"""Test the send-file route (file not found)."""
_ = config_conn
@@ -332,7 +332,7 @@ async def test_missing_send_file(client, config_conn):
assert response.status_code == 404
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_invalid_send_file(client, config_conn):
"""Test the send-file route (invalid filename)."""
_ = config_conn
@@ -357,7 +357,7 @@ def patch_os_remove_ok():
with patch.object(os, 'remove', new_remove) as wrapped_os:
yield wrapped_os
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_del_file_ok(client, config_conn, patch_os_remove_ok):
"""Test the del-file route with no error."""
_ = config_conn
@@ -367,7 +367,7 @@ async def test_del_file_ok(client, config_conn, patch_os_remove_ok):
assert response.status_code == 204
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_del_file_err(client, config_conn, patch_os_remove_err):
"""Test the send-file route with OSError."""
_ = config_conn
@@ -376,7 +376,7 @@ async def test_del_file_err(client, config_conn, patch_os_remove_err):
response = await client.delete ('/del-file/test.txt')
assert response.status_code == 404
@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_addon_links(client):
"""Test links to HA add-on config/log in UI"""
with patch.dict(os.environ, {'SLUG': 'c676133d', 'HOSTNAME': 'c676133d-tsun-proxy'}):