mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 23:00:18 +00:00
fix byte streaming endpoint in python3
This commit is contained in:
+1
-1
@@ -481,7 +481,7 @@ def stream_random_bytes(n):
|
||||
chunks = []
|
||||
|
||||
for i in xrange(n):
|
||||
chunks.append(chr(random.randint(0, 255)))
|
||||
chunks.append(os.urandom(1))
|
||||
if len(chunks) == chunk_size:
|
||||
yield(bytes().join(chunks))
|
||||
chunks = []
|
||||
|
||||
@@ -134,6 +134,11 @@ class HttpbinTestCase(unittest.TestCase):
|
||||
self.assertEqual(len(response.get_data()), 1024)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_stream_bytes(self):
|
||||
response = self.app.get('/stream-bytes/1024')
|
||||
self.assertEqual(len(response.get_data()), 1024)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user