Skip to content

Commit 62a9869

Browse files
committed
tests: use asyncio.run() instead of get_event_loop().run_until_complete()
asyncio.get_event_loop() no longer creates a loop implicitly (deprecated in 3.12, removed in 3.14), so every test using this helper raised 'RuntimeError: There is no current event loop in thread' and the suite could not be collected on a current interpreter. 175 passed on Python 3.14 after this change.
1 parent 20164b9 commit 62a9869

9 files changed

Lines changed: 11 additions & 11 deletions

tests/test_dongleless_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _patch(monkeypatch, reg):
7676

7777

7878
def _run(coro):
79-
return asyncio.get_event_loop().run_until_complete(coro)
79+
return asyncio.run(coro)
8080

8181

8282
def test_single_dongle_removes_orphan(monkeypatch):

tests/test_ota_snapshot_suppression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def _run(coro):
15-
return asyncio.get_event_loop().run_until_complete(coro)
15+
return asyncio.run(coro)
1616

1717

1818
def test_request_snapshot_suppressed_during_ota(coordinator, monkeypatch):

tests/test_reclaim_suffixed_ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _patch(monkeypatch, reg):
6767

6868

6969
def _run(coro):
70-
return asyncio.get_event_loop().run_until_complete(coro)
70+
return asyncio.run(coro)
7171

7272

7373
def test_shape_b_base_free_renames_down(monkeypatch):

tests/test_recovery_snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def _run(coro):
13-
return asyncio.get_event_loop().run_until_complete(coro)
13+
return asyncio.run(coro)
1414

1515

1616
def _prep(coordinator, monkeypatch):

tests/test_restore_entities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_restore_reenables_disabled(monkeypatch):
9090
migration = _install_er(monkeypatch, reg, entries)
9191

9292
import asyncio
93-
n = asyncio.get_event_loop().run_until_complete(
93+
n = asyncio.run(
9494
migration.async_restore_entities(MagicMock(), _Entry(), ["disabled:sensor.b"]))
9595
assert n == 1
9696
assert reg.async_get("sensor.b").disabled_by is None
@@ -102,7 +102,7 @@ def test_restore_purges_deleted(monkeypatch):
102102
migration = _install_er(monkeypatch, reg, [])
103103

104104
import asyncio
105-
n = asyncio.get_event_loop().run_until_complete(
105+
n = asyncio.run(
106106
migration.async_restore_entities(MagicMock(), _Entry(), ["deleted:sensor.gone"]))
107107
assert n == 1
108108
assert "sensor.gone" not in reg.deleted_entities # record cleared
@@ -113,7 +113,7 @@ def test_restore_ignores_unknown_keys(monkeypatch):
113113
reg = _FakeRegistry([], {})
114114
migration = _install_er(monkeypatch, reg, [])
115115
import asyncio
116-
n = asyncio.get_event_loop().run_until_complete(
116+
n = asyncio.run(
117117
migration.async_restore_entities(MagicMock(), _Entry(),
118118
["deleted:sensor.nope", "bogus", "disabled:"]))
119119
assert n == 0

tests/test_self_write_dedup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def _run(coro):
1717
import asyncio
18-
return asyncio.get_event_loop().run_until_complete(coro)
18+
return asyncio.run(coro)
1919

2020

2121
def _prep(coordinator, monkeypatch, entity_type="number"):

tests/test_snapshot_dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def _run(coro):
21-
return asyncio.get_event_loop().run_until_complete(coro)
21+
return asyncio.run(coro)
2222

2323

2424
@pytest.fixture(autouse=True)

tests/test_startup_gate_failsafe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def _run(coro):
16-
return asyncio.get_event_loop().run_until_complete(coro)
16+
return asyncio.run(coro)
1717

1818

1919
def _make_msg(topic, payload):

tests/test_unified_topics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def _run(coro):
2727
"""Tiny event-loop runner so each test can call async process_message."""
28-
return asyncio.get_event_loop().run_until_complete(coro)
28+
return asyncio.run(coro)
2929

3030

3131
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)