Skip to content

Use raw string literals if backslashes involved#37

Closed
maxnikulin wants to merge 1 commit intodanny0838:masterfrom
maxnikulin:fix-test-raw-literals
Closed

Use raw string literals if backslashes involved#37
maxnikulin wants to merge 1 commit intodanny0838:masterfrom
maxnikulin:fix-test-raw-literals

Conversation

@maxnikulin
Copy link
Copy Markdown
Contributor

Avoid ambiguity if backslashes start escape sequences.

Avoid ambiguity if backslashes start escape sequences.
@maxnikulin
Copy link
Copy Markdown
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 ============================

Comment thread test/test_server.py
""")

server.serve(server_root)
mock_browser.assert_called_once_with('"C:\Program Files\Mozilla Firefox\firefox.exe" %s &')
Copy link
Copy Markdown
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
Copy Markdown
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