-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
User agent for Python (and formerly Ruby, already merged) #5696
Conversation
Can you explain why you need these changes? |
Explanation is in the issue referenced in the description, but basically this is useful for error diagnosis in cloud services and grids. Similar changes have already been introduced for Java and .NET, so this is just rolling the feature out to more languages. |
Updated this PR to reflect just the Python change now that the Ruby change has been merged. |
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.
Would prefer if the test explicitly checked the platform
headers = { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
'User-Agent': 'Python http auth' | ||
'User-Agent': 'selenium/%s (python %s)' % (__version__, system) |
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.
Prefer str.format
for String Interpolation in the future
@@ -33,7 +34,8 @@ def test_get_remote_connection_headers_defaults(): | |||
assert 'Connection' not in headers.keys() | |||
assert headers.get('Accept') == 'application/json' | |||
assert headers.get('Content-Type') == 'application/json;charset=UTF-8' | |||
assert headers.get('User-Agent') == 'Python http auth' | |||
assert headers.get('User-Agent').startswith("selenium/%s (python " % __version__) | |||
assert headers.get('User-Agent').split(' ')[-1] in {'windows)', 'mac)', 'linux)'} |
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.
Is there a reason you aren't just asserting the entire User-Agent
? The second assertion could allow false positives if the wrong platform sent
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.
My reasoning was that asserting the whole thing requires duplicating the code to calculate the platform name, which proves nothing except that that code does whatever it does. This way if on OS X it returns "darwin" or on Windows it returns "win32", that issue will be caught when these tests are run on those platforms. I don't feel strongly about it though, happy to go a different route here if you prefer.
Merged, thanks! |
Addresses #5657 for Python and Ruby
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement