Trying to fix the tests
This commit is contained in:
@@ -42,7 +42,11 @@ def patch_webbrowser():
|
|||||||
for cmdline in reversed(_userchoices):
|
for cmdline in reversed(_userchoices):
|
||||||
if cmdline in ('safari', 'firefox', 'chrome', 'default'):
|
if cmdline in ('safari', 'firefox', 'chrome', 'default'):
|
||||||
browser = webbrowser.MacOSXOSAScript(cmdline)
|
browser = webbrowser.MacOSXOSAScript(cmdline)
|
||||||
webbrowser.register(cmdline, None, browser, -1)
|
try:
|
||||||
|
webbrowser.register(cmdline, None, browser, update_tryorder=-1)
|
||||||
|
except AttributeError:
|
||||||
|
# 3.7 nightly build changed the method signature
|
||||||
|
webbrowser.register(cmdline, None, browser, preferred=True)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
@@ -20,11 +20,16 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
# webbrowser's command to check if a file exists is different for py2/py3
|
||||||
|
if six.PY3:
|
||||||
|
mock_isfile = mock.patch('shutil.which', return_value=None)
|
||||||
|
else:
|
||||||
|
mock_isfile = mock.patch('os.path.isfile', return_value=None)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.dict(os.environ, {'BROWSER': 'safari'})
|
@mock.patch.dict(os.environ, {'BROWSER': 'safari'})
|
||||||
@mock.patch('sys.platform', 'darwin')
|
@mock.patch('sys.platform', 'darwin')
|
||||||
@mock.patch('shutil.which', return_value=None) # py3 method
|
@mock_isfile
|
||||||
@mock.patch('os.path.isfile', return_value=None) # py2 method
|
|
||||||
def test_patch_webbrowser(which, isfile):
|
def test_patch_webbrowser(which, isfile):
|
||||||
|
|
||||||
# Make sure that webbrowser re-generates the browser list using the
|
# Make sure that webbrowser re-generates the browser list using the
|
||||||
|
|||||||
Reference in New Issue
Block a user