Skip to content

Commit

Permalink
fix(test): decode response chunks in mock
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Dec 26, 2019
1 parent b8da77b commit e6e959b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions Makefile
Expand Up @@ -36,12 +36,18 @@ clean-coverage:
clean-package:
rm -rf dist

test: test-unit
test: test-unit-3

test-unit:
coverage run -m unittest discover -s tests/
coverage html
coverage xml
test-unit-2:
PYCMD=python2 $(MAKE) test-unit-N

test-unit-3:
PYCMD=python3 $(MAKE) test-unit-N

test-unit-N:
${PYCMD} -m coverage run -m unittest discover -s tests/
${PYCMD} -m coverage html
${PYCMD} -m coverage xml

package: clean-package package-dist package-upload

Expand Down
4 changes: 2 additions & 2 deletions tests/test_server.py
Expand Up @@ -14,7 +14,7 @@ def recv(self, n):
print('recv', n)
self.buffer = self.body[self.index : self.index + n]
self.index += n
return self.buffer.encode('utf-8')
return self.buffer.encode(ps.http_encoding)

def send(self, chunk):
self.accum.append(chunk)
Expand All @@ -23,7 +23,7 @@ def close(self):
self.open = False

def response(self):
return ''.join(self.accum)
return ''.join([x.decode(ps.http_encoding) for x in self.accum])

class MockSocket(object):
def __init__(self, addr, body):
Expand Down

0 comments on commit e6e959b

Please sign in to comment.