-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
RecordingConnection string handling issues #1253
Copy link
Copy link
Closed
Description
I was working on test coverage for topic search (see #1252). When recording an example API response, the test runner got thrown off by a non-breaking space in the content:
Traceback (most recent call last):
File "tests/Topic.py", line 67, in testSearch
self.assertListKeyEqual(self.g.search_topics("python"), attrgetter("name"), expected_names)
File "tests/Framework.py", line 312, in assertListKeyEqual
realKeys = [key(element) for element in elements]
File "github/PaginatedList.py", line 61, in __iter__
newElements = self._grow()
File "github/PaginatedList.py", line 73, in _grow
newElements = self._fetchNextPage()
File "github/PaginatedList.py", line 198, in _fetchNextPage
headers=self.__headers
File "github/Requester.py", line 268, in requestJsonAndCheck
return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
File "github/Requester.py", line 328, in requestJson
return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
File "github/Requester.py", line 381, in __requestEncode
status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input)
File "github/Requester.py", line 405, in __requestRaw
response = cnx.getresponse()
File "tests/Framework.py", line 129, in getresponse
self.__writeLine(output)
File "tests/Framework.py", line 140, in __writeLine
self.__file.write(line + '\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 2437: ordinal not in range(128)
I haven't looked too closely at the code, but this looks related to the fact that this class treats the response body as ASCII and UTF-8 in different places.
There's another issue with the same line in Python 3. Files opened in binary mode expect to receive bytes and '\n' is a string.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels