From 5437f6644f626c10159b57b7a666bd6ebc2bc0f5 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 10 Jan 2025 12:37:30 +0300 Subject: [PATCH 1/2] gh-128694: Fix `(env changed)` error in `test_inspect` --- Lib/test/test_inspect/test_inspect.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index 345a57a5cfee2d..346bd41f9c3926 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -1,4 +1,5 @@ from annotationlib import Format, ForwardRef +import asyncio import builtins import collections import copy @@ -49,6 +50,10 @@ from test.test_inspect import inspect_deferred_annotations +def tearDownModule(): + asyncio._set_event_loop_policy(None) + + # Functions tested in this suite: # ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode, # isbuiltin, isroutine, isgenerator, ispackage, isgeneratorfunction, getmembers, From 28764f17ba4419b7d28868a8d4275a500ede6bc7 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 10 Jan 2025 12:41:13 +0300 Subject: [PATCH 2/2] gh-128694: Fix `(env changed)` error in `test_inspect` --- Lib/test/test_inspect/test_inspect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index 346bd41f9c3926..6457bc523de460 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -50,10 +50,6 @@ from test.test_inspect import inspect_deferred_annotations -def tearDownModule(): - asyncio._set_event_loop_policy(None) - - # Functions tested in this suite: # ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode, # isbuiltin, isroutine, isgenerator, ispackage, isgeneratorfunction, getmembers, @@ -2796,6 +2792,10 @@ async def number_asyncgen(): async def asyncTearDown(self): await self.asyncgen.aclose() + @classmethod + def tearDownClass(cls): + asyncio._set_event_loop_policy(None) + def _asyncgenstate(self): return inspect.getasyncgenstate(self.asyncgen)