mirror of https://github.com/python/cpython.git
gh-127949: fix `DeprecationWarning` in test_inspect.py (#128215)
This commit is contained in:
parent
30efede33c
commit
3f6a618e49
|
@ -1,5 +1,4 @@
|
|||
from annotationlib import Format, ForwardRef
|
||||
import asyncio
|
||||
import builtins
|
||||
import collections
|
||||
import copy
|
||||
|
@ -73,11 +72,6 @@ def revise(filename, *args):
|
|||
git = mod.StupidGit()
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
if support.has_socket_support:
|
||||
asyncio._set_event_loop_policy(None)
|
||||
|
||||
|
||||
def signatures_with_lexicographic_keyword_only_parameters():
|
||||
"""
|
||||
Yields a whole bunch of functions with only keyword-only parameters,
|
||||
|
@ -205,7 +199,7 @@ def test_excluding_predicates(self):
|
|||
self.assertFalse(inspect.ismethodwrapper(type("AnyClass", (), {})))
|
||||
|
||||
def test_ispackage(self):
|
||||
self.istest(inspect.ispackage, 'asyncio')
|
||||
self.istest(inspect.ispackage, 'unittest')
|
||||
self.istest(inspect.ispackage, 'importlib')
|
||||
self.assertFalse(inspect.ispackage(inspect))
|
||||
self.assertFalse(inspect.ispackage(mod))
|
||||
|
@ -1166,16 +1160,20 @@ def f(self):
|
|||
# This is necessary when the test is run multiple times.
|
||||
sys.modules.pop("inspect_actual")
|
||||
|
||||
@unittest.skipIf(
|
||||
support.is_emscripten or support.is_wasi,
|
||||
"socket.accept is broken"
|
||||
)
|
||||
def test_nested_class_definition_inside_async_function(self):
|
||||
import asyncio
|
||||
self.addCleanup(asyncio.set_event_loop_policy, None)
|
||||
self.assertSourceEqual(asyncio.run(mod2.func225()), 226, 227)
|
||||
def run(coro):
|
||||
try:
|
||||
coro.send(None)
|
||||
except StopIteration as e:
|
||||
return e.value
|
||||
else:
|
||||
raise RuntimeError("coroutine did not complete synchronously!")
|
||||
finally:
|
||||
coro.close()
|
||||
|
||||
self.assertSourceEqual(run(mod2.func225()), 226, 227)
|
||||
self.assertSourceEqual(mod2.cls226, 231, 235)
|
||||
self.assertSourceEqual(asyncio.run(mod2.cls226().func232()), 233, 234)
|
||||
self.assertSourceEqual(run(mod2.cls226().func232()), 233, 234)
|
||||
|
||||
def test_class_definition_same_name_diff_methods(self):
|
||||
self.assertSourceEqual(mod2.cls296, 296, 298)
|
||||
|
|
Loading…
Reference in New Issue