|
1 | 1 | from annotationlib import Format, ForwardRef |
2 | | -import asyncio |
3 | 2 | import builtins |
4 | 3 | import collections |
5 | 4 | import copy |
@@ -73,11 +72,6 @@ def revise(filename, *args): |
73 | 72 | git = mod.StupidGit() |
74 | 73 |
|
75 | 74 |
|
76 | | -def tearDownModule(): |
77 | | - if support.has_socket_support: |
78 | | - asyncio._set_event_loop_policy(None) |
79 | | - |
80 | | - |
81 | 75 | def signatures_with_lexicographic_keyword_only_parameters(): |
82 | 76 | """ |
83 | 77 | Yields a whole bunch of functions with only keyword-only parameters, |
@@ -205,7 +199,7 @@ def test_excluding_predicates(self): |
205 | 199 | self.assertFalse(inspect.ismethodwrapper(type("AnyClass", (), {}))) |
206 | 200 |
|
207 | 201 | def test_ispackage(self): |
208 | | - self.istest(inspect.ispackage, 'asyncio') |
| 202 | + self.istest(inspect.ispackage, 'unittest') |
209 | 203 | self.istest(inspect.ispackage, 'importlib') |
210 | 204 | self.assertFalse(inspect.ispackage(inspect)) |
211 | 205 | self.assertFalse(inspect.ispackage(mod)) |
@@ -1166,16 +1160,20 @@ def f(self): |
1166 | 1160 | # This is necessary when the test is run multiple times. |
1167 | 1161 | sys.modules.pop("inspect_actual") |
1168 | 1162 |
|
1169 | | - @unittest.skipIf( |
1170 | | - support.is_emscripten or support.is_wasi, |
1171 | | - "socket.accept is broken" |
1172 | | - ) |
1173 | 1163 | def test_nested_class_definition_inside_async_function(self): |
1174 | | - import asyncio |
1175 | | - self.addCleanup(asyncio.set_event_loop_policy, None) |
1176 | | - self.assertSourceEqual(asyncio.run(mod2.func225()), 226, 227) |
| 1164 | + def run(coro): |
| 1165 | + try: |
| 1166 | + coro.send(None) |
| 1167 | + except StopIteration as e: |
| 1168 | + return e.value |
| 1169 | + else: |
| 1170 | + raise RuntimeError("coroutine did not complete synchronously!") |
| 1171 | + finally: |
| 1172 | + coro.close() |
| 1173 | + |
| 1174 | + self.assertSourceEqual(run(mod2.func225()), 226, 227) |
1177 | 1175 | self.assertSourceEqual(mod2.cls226, 231, 235) |
1178 | | - self.assertSourceEqual(asyncio.run(mod2.cls226().func232()), 233, 234) |
| 1176 | + self.assertSourceEqual(run(mod2.cls226().func232()), 233, 234) |
1179 | 1177 |
|
1180 | 1178 | def test_class_definition_same_name_diff_methods(self): |
1181 | 1179 | self.assertSourceEqual(mod2.cls296, 296, 298) |
|
0 commit comments