Пример #1
0
 def test_max_chunk_size(self):
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=None)) == [b"123456"]
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=1)) == [
         b"1", b"2", b"3", b"4", b"5", b"6"
     ]
Пример #2
0
 def test_chunked(self):
     rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar")
     body = b"".join(read_body(rfile, None))
     assert body == b"foo"
     assert rfile.read() == b"bar"
Пример #3
0
 def test_max_chunk_size(self):
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=None)) == [b"123456"]
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=1)) == [b"1", b"2", b"3", b"4", b"5", b"6"]
Пример #4
0
 def test_unknown_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, -1, 3))
Пример #5
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
Пример #6
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
Пример #7
0
 def test_known_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, 3))
     assert body == b"foo"
     assert rfile.read() == b"bar"
Пример #8
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
Пример #9
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
Пример #10
0
 def test_known_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, 3, 2))
Пример #11
0
 def test_known_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, 3))
     assert body == b"foo"
     assert rfile.read() == b"bar"
Пример #12
0
 def test_chunked(self):
     rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar")
     body = b"".join(read_body(rfile, None))
     assert body == b"foo"
     assert rfile.read() == b"bar"