From e2822360da30853f092d8a50ad83e52f6ea2ced9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 10 Jul 2024 13:11:46 +0300 Subject: gh-121571: Do not use `EnvironmentError` in tests, use `OSError` instead (#121572) --- Lib/test/support/__init__.py | 2 +- Lib/test/test_subprocess.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 18455bb..7f65793 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -387,7 +387,7 @@ def skip_if_buildbot(reason=None): reason = 'not suitable for buildbots' try: isbuildbot = getpass.getuser().lower() == 'buildbot' - except (KeyError, EnvironmentError) as err: + except (KeyError, OSError) as err: warnings.warn(f'getpass.getuser() failed {err}.', RuntimeWarning) isbuildbot = False return unittest.skipIf(isbuildbot, reason) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 8b69cd0..9412a2d 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1407,7 +1407,7 @@ class ProcessTestCase(BaseTestCase): t = threading.Thread(target=open_fds) t.start() try: - with self.assertRaises(EnvironmentError): + with self.assertRaises(OSError): subprocess.Popen(NONEXISTING_CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE, -- cgit v0.12