|
24 | 24 | # |
25 | 25 | ############################################################################### |
26 | 26 |
|
27 | | -import pytest |
28 | 27 | import txaio |
29 | 28 |
|
30 | 29 | from util import run_once |
@@ -90,50 +89,6 @@ def errback(f): |
90 | 89 | assert calls[0] == ((1, 2, 3), dict(key="word")) |
91 | 90 |
|
92 | 91 |
|
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 | | - |
137 | 92 | def test_as_future_exception(framework): |
138 | 93 | """ |
139 | 94 | Raises an exception from as_future |
|
0 commit comments