Skip to content

Commit 8076fbd

Browse files
authored
Fix 152 (#221)
* start new dev branch; add audit file * Remove dead @asyncio.coroutine legacy tests (#152) Three tests exercised the @asyncio.coroutine decorator via a try/except-ImportError that skipped on Python >= 3.11: - tests/test_is_future.py::test_is_future_coroutine - tests/test_as_future.py::test_as_future_coroutine - tests/test_call_later.py::test_explicit_reactor_coroutine @asyncio.coroutine was removed in Python 3.11, which is txaio's minimum supported version, so these tests could never run on any supported interpreter and only produced skips (and previously the deprecation warning this issue was filed about). Remove them, along with the now-unused `import pytest` in the two affected files (test_call_later.py still uses pytest/patch/sys for other tests). Suite: 105 passed, 10 skipped (was 106/14); ruff and ty clean. Note: This work was completed with AI assistance (Claude Code).
1 parent 10b46d7 commit 8076fbd

5 files changed

Lines changed: 9 additions & 99 deletions

File tree

.audit/oberstet_fix_152.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- [ ] I did **not** use any AI-assistance tools to help create this pull request.
2+
- [x] I **did** use AI-assistance tools to *help* create this pull request.
3+
- [x] I have read, understood and followed the projects' [AI Policy](https://github.com/crossbario/autobahn-python/blob/main/AI_POLICY.md) when creating code, documentation etc. for this pull request.
4+
5+
Submitted by: @oberstet
6+
Date: 2026-06-18
7+
Related issue(s): #152
8+
Branch: oberstet:fix_152

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This document contains a reverse-chronological list of changes to txaio.
1717

1818
**Other**
1919

20+
* Remove three permanently-skipped legacy tests that exercised the ``@asyncio.coroutine`` decorator. That decorator was removed in Python 3.11 (txaio's minimum supported version), so the tests could no longer run on any supported interpreter and only emitted skips (`#152 <https://github.com/crossbario/txaio/issues/152>`_)
2021
* Bumped the shared ``wamp-ai`` and ``wamp-cicd`` Git submodules to match the rest of the WAMP project group (zlmdb / autobahn-python 26.6.1) for the coordinated release. The ``wamp-cicd`` bump picks up the GHSA-6658 shell-injection hardening in the shared ``identifiers.yml`` reusable workflow (untrusted GitHub event fields are now passed via ``env:`` as quoted data with a fail-closed branch-name allowlist) (`#218 <https://github.com/crossbario/txaio/issues/218>`_)
2122
* Declare the ``ty`` type checker in the ``dev`` extra and run it from the project venv (dropping the separate global ``uv tool install ty`` step), so local and CI resolve the same latest ``ty``. Fixed a newly-reported ``ty`` ``invalid-argument-type`` diagnostic in ``tx.py`` (the Twisted ``ILogObserver`` is provided via ``zope.interface`` ``@provider``, which static checkers cannot follow) with a localized ``cast`` rather than a blanket rule ignore. Excluded the ``.ai`` / ``.cicd`` submodules from ``ruff`` (they carry their own linting/CI) (`#218 <https://github.com/crossbario/txaio/issues/218>`_)
2223

tests/test_as_future.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#
2525
###############################################################################
2626

27-
import pytest
2827
import txaio
2928

3029
from util import run_once
@@ -90,50 +89,6 @@ def errback(f):
9089
assert calls[0] == ((1, 2, 3), dict(key="word"))
9190

9291

93-
def test_as_future_coroutine(framework):
94-
"""
95-
call a coroutine (asyncio)
96-
"""
97-
pytest.importorskip("asyncio")
98-
# can import asyncio on python3.4, but might still be using
99-
# twisted
100-
if not txaio.using_asyncio:
101-
return
102-
try:
103-
from asyncio import coroutine
104-
except ImportError:
105-
pytest.skip(
106-
"skipping test: @asyncio.coroutine decorator is removed since Python 3.11"
107-
)
108-
else:
109-
errors = []
110-
results = []
111-
calls = []
112-
113-
@coroutine
114-
def method(*args, **kw):
115-
calls.append((args, kw))
116-
return 42
117-
118-
f = txaio.as_future(method, 1, 2, 3, key="word")
119-
120-
def cb(x):
121-
results.append(x)
122-
123-
def errback(f):
124-
errors.append(f)
125-
126-
txaio.add_callbacks(f, cb, errback)
127-
128-
run_once()
129-
run_once()
130-
131-
assert len(results) == 1
132-
assert len(errors) == 0
133-
assert results[0] == 42
134-
assert calls[0] == ((1, 2, 3), dict(key="word"))
135-
136-
13792
def test_as_future_exception(framework):
13893
"""
13994
Raises an exception from as_future

tests/test_call_later.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -167,38 +167,6 @@ def boom(r):
167167
assert results == [the_exception]
168168

169169

170-
def test_explicit_reactor_coroutine(framework):
171-
"""
172-
If we set an event-loop, Futures + Tasks should use it.
173-
"""
174-
pytest.importorskip("asyncio")
175-
if txaio.using_twisted:
176-
pytest.skip()
177-
try:
178-
from asyncio import coroutine
179-
except ImportError:
180-
pytest.skip(
181-
"skipping test: @asyncio.coroutine decorator is removed since Python 3.11"
182-
)
183-
else:
184-
185-
@coroutine
186-
def some_coroutine():
187-
yield "nothing"
188-
189-
with patch.object(txaio.config, "loop") as fake_loop:
190-
txaio.as_future(some_coroutine)
191-
192-
if sys.version_info < (3, 4, 2):
193-
assert len(fake_loop.method_calls) == 2
194-
c = fake_loop.method_calls[1]
195-
assert c[0] == "call_soon"
196-
else:
197-
assert len(fake_loop.method_calls) == 1
198-
c = fake_loop.method_calls[0]
199-
assert c[0] == "create_task"
200-
201-
202170
def test_call_later_tx(framework_tx):
203171
"""
204172
Wait for two Futures.

tests/test_is_future.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#
2525
###############################################################################
2626

27-
import pytest
2827
import txaio
2928

3029

@@ -37,27 +36,6 @@ def test_is_future_generic(framework):
3736
assert txaio.is_future(f)
3837

3938

40-
def test_is_future_coroutine(framework_aio):
41-
"""
42-
Returning an immediate value from as_future
43-
"""
44-
pytest.importorskip("asyncio") # 'aio' might be using trollius
45-
try:
46-
from asyncio import coroutine
47-
except ImportError:
48-
pytest.skip(
49-
"skipping test: @asyncio.coroutine decorator is removed since Python 3.11"
50-
)
51-
else:
52-
53-
@coroutine
54-
def some_coroutine():
55-
yield "answer"
56-
57-
obj = some_coroutine()
58-
assert txaio.is_future(obj)
59-
60-
6139
def test_is_called(framework):
6240
f = txaio.create_future_success(None)
6341
assert txaio.is_called(f)

0 commit comments

Comments
 (0)