mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 23:00:18 +00:00
Fix bytes endpoint in python3
This commit is contained in:
+1
-1
@@ -458,7 +458,7 @@ def random_bytes(n):
|
||||
random.seed(int(params['seed']))
|
||||
|
||||
response = make_response()
|
||||
response.data = bytes().join(chr(random.randint(0, 255)) for i in xrange(n))
|
||||
response.data = os.urandom(n)
|
||||
response.content_type = 'application/octet-stream'
|
||||
return response
|
||||
|
||||
|
||||
@@ -129,6 +129,10 @@ class HttpbinTestCase(unittest.TestCase):
|
||||
self.assertEqual(len(response.get_data()), 400)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_get_bytes(self):
|
||||
response = self.app.get('/bytes/1024')
|
||||
self.assertEqual(len(response.get_data()), 1024)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user