Skip to content

Use raw string literals if backslashes involved #37

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

Closed

Conversation

maxnikulin
Copy link
Contributor

Avoid ambiguity if backslashes start escape sequences.

Avoid ambiguity if backslashes start escape sequences.
@maxnikulin
Copy link
Contributor Author

I was checking if pytest could provide more informative report for #34

python3 -m pytest test

...

=============================== warnings summary ===============================
test/test_server.py:218
  /home/ubuntu/danny0838/PyWebScrapBook/test/test_server.py:218: DeprecationWarning: invalid escape sequence \P
    f.write("""[server]

test/test_server.py:227
  /home/ubuntu/danny0838/PyWebScrapBook/test/test_server.py:227: DeprecationWarning: invalid escape sequence \P
    mock_browser.assert_called_once_with('"C:\Program Files\Mozilla Firefox\firefox.exe" %s &')

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================

@@ -224,7 +224,7 @@ def test_command3(self, mock_make_server, mock_browser):
""")

server.serve(server_root)
mock_browser.assert_called_once_with('"C:\Program Files\Mozilla Firefox\firefox.exe" %s &')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, is there any protection against peculiar arguments for substitutions? On linux I strongly prefer something from execve(2) family that has each command line argument as a separate array element.

Path to firefox at least surrounded with quotes... Is it assumed that argument for the %s substitution is passed through urlencode, so it is safe?

danny0838 pushed a commit that referenced this pull request Dec 21, 2020
Avoid ambiguity if backslashes start escape sequences.
@danny0838
Copy link
Owner

Implemented with slightly fix.

@danny0838 danny0838 closed this Dec 21, 2020
@maxnikulin maxnikulin deleted the fix-test-raw-literals branch December 22, 2020 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants