diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-07-22 21:42:57 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-07-22 21:42:57 +0000 |
commit | 686597b52a7b64161ca82e468a401efe22553a22 (patch) | |
tree | d24aa2a0ae5ea6b33cd7cad3a7703f00085b2cdd | |
parent | c95fdbc5c54052eec30663b7ac82349c6539e2d2 (diff) | |
parent | 19dda6d891a96215aa21c09994526e9b7d61399d (diff) | |
download | keystone-2014.2.b2.tar.gz |
Merge "Fixes test_exceptions.py for Python3"2014.2.b2
-rw-r--r-- | keystone/tests/matchers.py | 6 | ||||
-rw-r--r-- | keystone/tests/test_exception.py | 8 | ||||
-rw-r--r-- | keystone/tests/test_matchers.py | 6 | ||||
-rw-r--r-- | tox.ini | 1 |
4 files changed, 11 insertions, 10 deletions
diff --git a/keystone/tests/matchers.py b/keystone/tests/matchers.py index f904d339c..1b928c0c9 100644 --- a/keystone/tests/matchers.py +++ b/keystone/tests/matchers.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import six +import io from lxml import etree from testtools import matchers @@ -35,13 +35,13 @@ class XMLEquals(object): def canonical_xml(s): s = s.strip() - fp = six.StringIO() + fp = io.BytesIO() dom = etree.fromstring(s, parser) dom.getroottree().write_c14n(fp) s = fp.getvalue() dom = etree.fromstring(s, parser) - return etree.tostring(dom, pretty_print=True) + return etree.tostring(dom, pretty_print=True).decode('utf-8') expected = canonical_xml(self.expected) other = canonical_xml(other) diff --git a/keystone/tests/test_exception.py b/keystone/tests/test_exception.py index 3a64578da..a7cb7c3e3 100644 --- a/keystone/tests/test_exception.py +++ b/keystone/tests/test_exception.py @@ -89,15 +89,15 @@ class ExceptionTestCase(tests.TestCase): e = exception.ValidationError(attribute='xx', target='Long \xe2\x80\x93 Dash') - self.assertIn(u'\u2013', e.message) + self.assertIn(u'\u2013', six.text_type(e)) def test_invalid_unicode_string(self): # NOTE(jamielennox): This is a complete failure case so what is - # returned in the e.message is not that important so long as there is - # an error with a message + # returned in the exception message is not that important so long + # as there is an error with a message e = exception.ValidationError(attribute='xx', target='\xe7a va') - self.assertIn('%(attribute)', e.message) + self.assertIn('%(attribute)', six.text_type(e)) class UnexpectedExceptionTestCase(ExceptionTestCase): diff --git a/keystone/tests/test_matchers.py b/keystone/tests/test_matchers.py index 092fa8314..d4215f1ce 100644 --- a/keystone/tests/test_matchers.py +++ b/keystone/tests/test_matchers.py @@ -21,19 +21,19 @@ from keystone.tests import matchers class TestXMLEquals(tests.BaseTestCase, helpers.TestMatchersInterface): - matches_xml = """ + matches_xml = b""" <?xml version="1.0" encoding="UTF-8"?> <test xmlns="http://docs.openstack.org/identity/api/v2.0"> <success a="a" b="b"/> </test> """ - equivalent_xml = """ + equivalent_xml = b""" <?xml version="1.0" encoding="UTF-8"?> <test xmlns="http://docs.openstack.org/identity/api/v2.0"> <success b="b" a="a"></success> </test> """ - mismatches_xml = """ + mismatches_xml = b""" <?xml version="1.0" encoding="UTF-8"?> <test xmlns="http://docs.openstack.org/identity/api/v2.0"> <nope_it_fails/> @@ -27,6 +27,7 @@ commands = keystone/tests/test_driver_hints.py \ keystone/tests/test_hacking_checks.py \ keystone/tests/test_injection.py \ + keystone/tests/test_matchers.py \ keystone/tests/test_policy.py \ keystone/tests/test_s3_token_middleware.py \ keystone/tests/test_singular_plural.py \ |