Py3 compatibility fixes

This commit is contained in:
Pedro Algarvio 2014-11-22 11:25:07 +00:00
parent 403abc88e1
commit 46add23cc1

View file

@ -27,14 +27,20 @@
#
# Modified from the original. See the Git history of this file for details.
# https://bitbucket.org/Lawouach/cherrypy-recipes/src/50aff88dc4e24206518ec32e1c32af043f2729da/testing/unit/serverless/cptestcase.py
from __future__ import absolute_import
from StringIO import StringIO
import cherrypy
# Import Python libs
from __future__ import absolute_import, print_function
# Import Salt Testing libs
from salttesting.case import TestCase
# Import 3rd-party libs
# pylint: disable=import-error
import cherrypy
import salt.ext.six as six
from salt.ext.six.moves import StringIO
# pylint: enable=import-error
# Not strictly speaking mandatory but just makes sense
cherrypy.config.update({'environment': "test_suite"})
@ -104,7 +110,7 @@ class BaseCherryPyTestCase(TestCase):
# Let's fake the local and remote addresses
request, response = app.get_serving(local, remote, scheme, proto)
try:
h = [(k, v) for k, v in h.iteritems()]
h = [(k, v) for k, v in six.iteritems(h)]
response = request.run(method, path, qs, proto, h, fd)
finally:
if fd:
@ -112,7 +118,7 @@ class BaseCherryPyTestCase(TestCase):
fd = None
if response.output_status.startswith('500'):
print response.body
print(response.body)
raise AssertionError("Unexpected error")
# collapse the response into a bytestring