Skip to content

Commit 129a612

Browse files
committed
Fixed test encoding for Python 3.
1 parent 90474d2 commit 129a612

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import _setup
22

33
import os
4+
import sys
45
import unittest
56

67
from email import message_from_file
@@ -11,6 +12,10 @@
1112
from github2.request import charset_from_headers
1213

1314

15+
if sys.version_info[0] == 2:
16+
bytes = lambda x, enc: x
17+
18+
1419
HTTP_DATA_DIR = "tests/data/"
1520

1621
ORIG_HTTP_OBJECT = httplib2.Http
@@ -37,7 +42,7 @@ def request(self, uri, method='GET', body=None, headers=None,
3742
if os.path.exists(file):
3843
response = message_from_file(open(file))
3944
headers = httplib2.Response(response)
40-
body = response.get_payload().encode(charset_from_headers(headers))
45+
body = bytes(response.get_payload(), charset_from_headers(headers))
4146
return (headers, body)
4247
else:
4348
return (httplib2.Response({"status": "404"}),

0 commit comments

Comments
 (0)