Skip to content
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

Feature/python3 update #63

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

jerry57
Copy link

@jerry57 jerry57 commented Dec 12, 2019

No description provided.

viktoras25 and others added 30 commits August 2, 2013 20:23
Added a simply echo server to the mock server (copied from POST statement).
Added a test in simple.txt test framework. Moved the old 'Custom HTTP' verb test to use OPTIONS instead of PATCH.
… take use a variable as a parameter for the GET command. Remove the quotes if needed.
Added OPTIONS as main keyword
Keep the symmetry with set_request_body() which encodes the unicode
object (Robot Framework defaults to unicode for all strings) into an
instance of str by decoding the response into an instance of unicode in
get_response_body().

Failure to do so causes UnicodeDecodeErrors in all keywords that compare
the response body against a given string if any of the two contains
Unicode characters.
Robot Framework defaults to unicode objects for all strings created. As
a result, httplib.py:848 has unicode += str (msg += message_body) which
crashes with UnicodeDecodeError when the body contains Unicode
characters:

  File "/usr/lib64/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 848, in _send_output
    msg += message_body
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 32: ordinal not in range(128)

A similar stack trace has been posted as part of Python bug #11898 [1]
(duplicated by #12398 [2]) which has later been closed as a programming
error.

Both robotframework-httplibrary and webtest treat the 'Content-Type'
header special which results in surprising behavior regarding the tests:
Had the 'Accept' header been removed from the provided test case no
UnicodeDecodeError would have been thrown in httplib.py:848.

Turning unicode objects into str objects is the right thing to do
according to the HTTP standard ([3], updated by [5]) because it requires
conformity to MIME [5] (hint by [6]).

[1] http://bugs.python.org/issue11898
[2] http://bugs.python.org/issue12398
[3] https://tools.ietf.org/html/rfc2616
[4] https://tools.ietf.org/html/rfc2047
[5] https://tools.ietf.org/html/rfc7230
[6] https://stackoverflow.com/a/5426648
Honors Robot Framework formatting on Github.
fixed set_json_value method when json_value has a string
- Improvement: Added stringify parameter to json_value_should_equal and json_value_should_not_equal methods
This will remove the specified JSON key from JSON. Till not we had only "set_json_value".
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.

9 participants