self._check_registration(preferred=True)
+ @unittest.skipUnless(sys.platform == "darwin", "macOS specific test")
+ def test_no_xdg_settings_on_macOS(self):
+ # On macOS webbrowser should not use xdg-settings to
+ # look for X11 based browsers (for those users with
+ # XQuartz installed)
+ with mock.patch("subprocess.check_output") as ck_o:
+ webbrowser.register_standard_browsers()
+
+ ck_o.assert_not_called()
+
+
class ImportTest(unittest.TestCase):
def test_register(self):
webbrowser = import_helper.import_fresh_module('webbrowser')
register("microsoft-edge", None, Edge("MicrosoftEdge.exe"))
else:
# Prefer X browsers if present
- if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
+ #
+ # NOTE: Do not check for X11 browser on macOS,
+ # XQuartz installation sets a DISPLAY environment variable and will
+ # autostart when someone tries to access the display. Mac users in
+ # general don't need an X11 browser.
+ if sys.platform != "darwin" and (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")):
try:
cmd = "xdg-settings get default-web-browser".split()
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)