-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-31014: webbrowser._synthesize
calls webbrowser.register
with outdated signature
#2689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
import subprocess | ||
from unittest import mock | ||
from test import support | ||
from test.support import script_helper | ||
import textwrap | ||
|
||
|
||
URL = 'http://www.example.com' | ||
|
@@ -265,6 +267,23 @@ def test_register_default(self): | |
def test_register_preferred(self): | ||
self._check_registration(preferred=True) | ||
|
||
def test_environment_variable_BROWSER_is_respected(self): | ||
script_helper.assert_python_ok("-c", textwrap.dedent(""" | ||
import shutil, unittest | ||
from test import support, test_webbrowser | ||
|
||
def mock_which(path): | ||
return True | ||
|
||
class Test(test_webbrowser.ImportTest): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I almost missed that this re-ran the I think that's OK as a test case, but it would be clearer as part of a dedicated |
||
|
||
def setUp(self): | ||
super().setUp() | ||
support.patch(self, shutil, 'which', mock_which) | ||
|
||
unittest.main() | ||
"""), BROWSER='test_browser') | ||
|
||
|
||
class ImportTest(unittest.TestCase): | ||
def test_register(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ def open_new_tab(url): | |
return open(url, 2) | ||
|
||
|
||
def _synthesize(browser, update_tryorder=1): | ||
def _synthesize(browser, update_tryorder=True): | ||
"""Attempt to synthesize a controller base on existing controllers. | ||
|
||
This is useful to create a controller when a user specifies a path to | ||
|
@@ -113,7 +113,7 @@ def _synthesize(browser, update_tryorder=1): | |
controller = copy.copy(controller) | ||
controller.name = browser | ||
controller.basename = os.path.basename(browser) | ||
register(browser, None, controller, update_tryorder) | ||
register(browser, None, instance=controller, preferred=update_tryorder) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update tryorder is now a boolean as requested. |
||
return [None, controller] | ||
return [None, None] | ||
|
||
|
@@ -564,7 +564,7 @@ def register_standard_browsers(): | |
# and prepend to _tryorder | ||
for cmdline in userchoices: | ||
if cmdline != '': | ||
cmd = _synthesize(cmdline, -1) | ||
cmd = _synthesize(cmdline, update_tryorder=False) | ||
if cmd[1] is None: | ||
register(cmdline, None, GenericBrowser(cmdline), preferred=True) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does accurately catch the regression as far as I can tell but it seems a little obscure. Thoughts?