diff --git a/rtv/objects.py b/rtv/objects.py index 7113a82..64116df 100644 --- a/rtv/objects.py +++ b/rtv/objects.py @@ -42,7 +42,11 @@ def patch_webbrowser(): for cmdline in reversed(_userchoices): if cmdline in ('safari', 'firefox', 'chrome', 'default'): 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 diff --git a/tests/test_objects.py b/tests/test_objects.py index 31b0c30..3d797a8 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -20,11 +20,16 @@ try: except ImportError: 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('sys.platform', 'darwin') -@mock.patch('shutil.which', return_value=None) # py3 method -@mock.patch('os.path.isfile', return_value=None) # py2 method +@mock_isfile def test_patch_webbrowser(which, isfile): # Make sure that webbrowser re-generates the browser list using the