diff options
| author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-10-17 15:27:02 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-17 15:27:02 (GMT) |
| commit | 72c10d3f1a6d42b70cc4b843295361db17cc0964 (patch) | |
| tree | 43f981f89da42ac037b2eb936675a969ba810f6a /Lib/test/test_asyncio/test_subprocess.py | |
| parent | 6da1a2e993c955aa69158871b8c8792cef3094c3 (diff) | |
| download | cpython-72c10d3f1a6d42b70cc4b843295361db17cc0964.zip cpython-72c10d3f1a6d42b70cc4b843295361db17cc0964.tar.gz cpython-72c10d3f1a6d42b70cc4b843295361db17cc0964.tar.bz2 | |
GH-98327: Reduce scope of catch_warnings() in _make_subprocess_transport (#98333)
Alas, warnings.catch_warnings() has global scope, not thread scope, so this is still not perfect, but it reduces the time during which warnings are ignored. Better solution welcome.
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_subprocess.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index 8e55115..fe1d060 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -752,15 +752,11 @@ if sys.platform != 'win32': class GenericWatcherTests(test_utils.TestCase): def test_create_subprocess_fails_with_inactive_watcher(self): - watcher = mock.create_autospec( - asyncio.AbstractChildWatcher, - **{"__enter__.return_value.is_active.return_value": False} - ) + watcher = mock.create_autospec(asyncio.AbstractChildWatcher) + watcher.is_active.return_value = False async def execute(): - with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - asyncio.set_child_watcher(watcher) + asyncio.set_child_watcher(watcher) with self.assertRaises(RuntimeError): await subprocess.create_subprocess_exec( @@ -774,9 +770,9 @@ if sys.platform != 'win32': self.assertIsNone(runner.run(execute())) self.assertListEqual(watcher.mock_calls, [ mock.call.__enter__(), - mock.call.__enter__().is_active(), + mock.call.is_active(), mock.call.__exit__(RuntimeError, mock.ANY, mock.ANY), - ]) + ], watcher.mock_calls) @unittest.skipUnless( |
