diff --git a/Lib/test/test_webbrowser.py b/Lib/test/test_webbrowser.py index 870ddd7349f494..4c3ea1cd8df13e 100644 --- a/Lib/test/test_webbrowser.py +++ b/Lib/test/test_webbrowser.py @@ -321,7 +321,13 @@ def close(self): @unittest.skipUnless(sys.platform == "darwin", "macOS specific test") @requires_subprocess() class MacOSXOSAScriptTest(unittest.TestCase): + def setUp(self): + # Ensure that 'BROWSER' is not set to 'open' or something else. + # See: https://github.com/python/cpython/issues/131254. + env = self.enterContext(os_helper.EnvironmentVarGuard()) + env.unset("BROWSER") + support.patch(self, os, "popen", self.mock_popen) self.browser = webbrowser.MacOSXOSAScript("default")