Fixes for open_graphical_browser, fixes #754

This commit is contained in:
Markus Unterwaditzer 2018-07-19 21:14:30 +02:00
parent aec9b91602
commit 80a42e4c6c
2 changed files with 10 additions and 5 deletions

View file

@ -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', [])

View file

@ -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