Skip to content

Commit

Permalink
fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet committed Jan 9, 2017
1 parent 0f8d98e commit c218ed7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,13 @@ def test_read_chunk_properly_counts_read_bytes(self):
self.assertEqual(b'.' * size, result)
self.assertTrue(obj.at_eof())

def test_read_does_reads_boundary(self):
def test_read_does_not_read_boundary(self):
stream = Stream(b'Hello, world!\r\n--:')
obj = aiohttp.multipart.BodyPartReader(
self.boundary, {}, stream)
result = yield from obj.read()
self.assertEqual(b'Hello, world!', result)
self.assertEqual(b'', (yield from stream.read()))
self.assertEqual([b'--:'], list(obj._unread))
self.assertEqual(b'--:', (yield from stream.read()))

def test_multiread(self):
obj = aiohttp.multipart.BodyPartReader(
Expand Down Expand Up @@ -474,8 +473,7 @@ def test_release(self):
self.boundary, {}, stream)
yield from obj.release()
self.assertTrue(obj.at_eof())
self.assertEqual(b'\r\nworld!\r\n--:--', stream.content.read())
self.assertEqual([b'--:\r\n'], list(obj._unread))
self.assertEqual(b'--:\r\n\r\nworld!\r\n--:--', stream.content.read())

def test_release_respects_content_length(self):
obj = aiohttp.multipart.BodyPartReader(
Expand All @@ -491,8 +489,7 @@ def test_release_release(self):
self.boundary, {}, stream)
yield from obj.release()
yield from obj.release()
self.assertEqual(b'\r\nworld!\r\n--:--', stream.content.read())
self.assertEqual([b'--:\r\n'], list(obj._unread))
self.assertEqual(b'--:\r\n\r\nworld!\r\n--:--', stream.content.read())

def test_filename(self):
part = aiohttp.multipart.BodyPartReader(
Expand Down
6 changes: 6 additions & 0 deletions tests/test_py35/test_multipart_35.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ def __init__(self, content):
async def read(self, size=None):
return self.content.read(size)

def at_eof(self):
return self.content.tell() == len(self.content.getbuffer())

async def readline(self):
return self.content.readline()

def unread_data(self, data):
self.content = io.BytesIO(data + self.content.read())


async def test_async_for_reader(loop):
data = [{"test": "passed"}, 42, b'plain text', b'aiohttp\n']
Expand Down

0 comments on commit c218ed7

Please sign in to comment.