Python 3: enable tests/unit/middleware/test_request_id.py

In Python 3, webob will return bytes, so we need to fix generate_request_id()
so that it also returns bytes. The behaviour is unchanged in Python 2.

Change-Id: I389cf20e4c999c9bb576a42388497852f8ba27ec
This commit is contained in:
Cyril Roelandt 2014-03-13 17:45:14 +01:00
parent 6b0939d2fb
commit 85d1ce6e55
3 changed files with 3 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import uuid
def generate_request_id():
return 'req-%s' % str(uuid.uuid4())
return b'req-' + str(uuid.uuid4()).encode('ascii')
class RequestContext(object):

View File

@ -32,6 +32,6 @@ class RequestIdTest(test.BaseTestCase):
req = webob.Request.blank('/test')
res = req.get_response(app)
res_req_id = res.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID)
self.assertThat(res_req_id, matchers.StartsWith('req-'))
self.assertThat(res_req_id, matchers.StartsWith(b'req-'))
# request-id in request environ is returned as response body
self.assertEqual(res_req_id, res.body)

View File

@ -69,6 +69,7 @@ commands =
tests/unit/middleware/test_catch_errors.py \
tests/unit/middleware/test_correlation_id.py \
tests/unit/middleware/test_notifier.py \
tests/unit/middleware/test_request_id.py \
tests/unit/rpc/test_dispatcher.py \
tests/unit/scheduler/test_host_filters.py \
tests/unit/test_cfgfilter.py \