From 80a42e4c6c18ca4db737bc6700c50a3866832bbb Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Thu, 19 Jul 2018 21:14:30 +0200 Subject: [PATCH] Fixes for open_graphical_browser, fixes #754 --- tests/system/utils/test_main.py | 12 +++++++----- vdirsyncer/utils.py | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/system/utils/test_main.py b/tests/system/utils/test_main.py index 50c5537..d25b0d0 100644 --- a/tests/system/utils/test_main.py +++ b/tests/system/utils/test_main.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- +import sys import logging import click_log - import pytest - import requests from vdirsyncer import http, utils @@ -64,9 +63,12 @@ def test_request_ssl_fingerprints(httpsserver, fingerprint): def test_open_graphical_browser(monkeypatch): import webbrowser - # Just assert that this internal attribute still exists and is some sort of - # collection. - iter(webbrowser._tryorder) + # Just assert that this internal attribute still exists and behaves the way + # expected + if sys.version_info < (3, 7): + iter(webbrowser._tryorder) + else: + assert webbrowser._tryorder is None monkeypatch.setattr('webbrowser._tryorder', []) diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 0ef355e..6527eff 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -215,6 +215,9 @@ def open_graphical_browser(url, new=0, autoraise=True): cli_names = set(['www-browser', 'links', 'links2', 'elinks', 'lynx', 'w3m']) + if webbrowser._tryorder is None: # Python 3.7 + webbrowser.register_standard_browsers() + for name in webbrowser._tryorder: if name in cli_names: continue