Skip to content

Commit

Permalink
Fixes for open_graphical_browser, fixes #754
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Jul 19, 2018
1 parent aec9b91 commit 80a42e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/system/utils/test_main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-

import sys
import logging

import click_log

import pytest

import requests

from vdirsyncer import http, utils
Expand Down Expand Up @@ -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', [])

Expand Down
3 changes: 3 additions & 0 deletions vdirsyncer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80a42e4

Please sign in to comment.