Skip to content

Commit

Permalink
test 8bit and 7bit transfer encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Mar 8, 2017
1 parent 1ce1912 commit cd18886
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,17 @@ def test_read_with_content_transfer_encoding_quoted_printable(self):
self.assertEqual(b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82,'
b' \xd0\xbc\xd0\xb8\xd1\x80!', result)

@pytest.mark.parametrize('encoding', [])
def test_read_with_content_transfer_encoding_binary(self):
obj = aiohttp.multipart.BodyPartReader(
self.boundary, {CONTENT_TRANSFER_ENCODING: 'binary'},
Stream(b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82,'
b' \xd0\xbc\xd0\xb8\xd1\x80!\r\n--:--'))
result = yield from obj.read(decode=True)
self.assertEqual(b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82,'
b' \xd0\xbc\xd0\xb8\xd1\x80!', result)
data = b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82,' \
b' \xd0\xbc\xd0\xb8\xd1\x80!'
for encoding in ('binary', '8bit', '7bit'):
with self.subTest(encoding):
obj = aiohttp.multipart.BodyPartReader(
self.boundary, {CONTENT_TRANSFER_ENCODING: encoding},
Stream(data + b'\r\n--:--'))
result = yield from obj.read(decode=True)
self.assertEqual(data, result)

def test_read_with_content_transfer_encoding_unknown(self):
obj = aiohttp.multipart.BodyPartReader(
Expand Down

0 comments on commit cd18886

Please sign in to comment.