tests: fix DeprecationWarnings for py3.14: asyncio.iscoroutinefunction
What changed, and why it matters
This commit only updates test helper code to stop using a Python function that will be removed in a future Python version. It does not change Electrum's wallet, networking, or cryptography code, and it does not fix any security bug.
No security action needed. Treat as routine test-maintenance cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit replaces asyncio.iscoroutinefunction(func) with inspect.iscoroutinefunction(func) in four places inside the test suite (tests/__init__.py and tests/test_bitcoin.py). This is a compatibility change to avoid DeprecationWarning introduced in Python 3.14, matching the approach from an earlier pull request. The change is purely in test decorators and has no effect on production code paths.
Changed components
tests/__init__.pytests/test_bitcoin.pyInspect captured patch +6 / −4
diff --git a/tests/__init__.py b/tests/__init__.py
index 106323e..b2b649b 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -5,6 +5,7 @@ import threading
import tempfile
import shutil
import functools
+import inspect
import electrum
import electrum.logging
@@ -88,7 +89,7 @@ def as_testnet(func):
NOTE: this is inherently sequential; tests running in parallel would break things
"""
old_net = constants.net
- if asyncio.iscoroutinefunction(func):
+ if inspect.iscoroutinefunction(func):
async def run_test(*args, **kwargs):
try:
constants.BitcoinTestnet.set_as_network()
diff --git a/tests/test_bitcoin.py b/tests/test_bitcoin.py
index 9ce265b..5673dc2 100644
--- a/tests/test_bitcoin.py
+++ b/tests/test_bitcoin.py
@@ -3,6 +3,7 @@ import base64
import json
import os
import sys
+import inspect
import electrum_ecc as ecc
@@ -46,7 +47,7 @@ def needs_test_with_all_aes_implementations(func):
has_cryptodome = crypto.HAS_CRYPTODOME
has_cryptography = crypto.HAS_CRYPTOGRAPHY
has_pyaes = crypto.HAS_PYAES
- if asyncio.iscoroutinefunction(func):
+ if inspect.iscoroutinefunction(func):
async def run_test(*args, **kwargs):
try:
if has_pyaes:
@@ -92,7 +93,7 @@ def needs_test_with_all_chacha20_implementations(func):
return func
has_cryptodome = crypto.HAS_CRYPTODOME
has_cryptography = crypto.HAS_CRYPTOGRAPHY
- if asyncio.iscoroutinefunction(func):
+ if inspect.iscoroutinefunction(func):
async def run_test(*args, **kwargs):
try:
if has_cryptodome:
@@ -128,7 +129,7 @@ def disable_ecdsa_r_value_grinding(func):
tests running in parallel would break things
"""
is_grinding = ecc.ENABLE_ECDSA_R_VALUE_GRINDING
- if asyncio.iscoroutinefunction(func):
+ if inspect.iscoroutinefunction(func):
async def run_test(*args, **kwargs):
try:
ecc.ENABLE_ECDSA_R_VALUE_GRINDING = False
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.