From a908d691490818aa03fbdb0d3f96448e8edbb8cf Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 16 Jun 2015 21:35:24 -0500 Subject: Conditionally construct the repr of NameAttributes --- tests/test_x509.py | 36 ++++++++++++++++++++++++++---------- tests/test_x509_ext.py | 26 +++++++++++++++++--------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/tests/test_x509.py b/tests/test_x509.py index 53ddeb84..547aa58e 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -10,6 +10,8 @@ import os import pytest +import six + from cryptography import x509 from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends.interfaces import ( @@ -825,10 +827,16 @@ class TestNameAttribute(object): def test_repr(self): na = x509.NameAttribute(x509.ObjectIdentifier('2.5.4.3'), u'value') - assert repr(na) == ( - ", value=u'value')>" - ) + if six.PY3: + assert repr(na) == ( + ", value='value')>" + ) + else: + assert repr(na) == ( + ", value=u'value')>" + ) class TestObjectIdentifier(object): @@ -879,9 +887,17 @@ class TestName(object): x509.NameAttribute(x509.OID_ORGANIZATION_NAME, u'PyCA'), ]) - assert repr(name) == ( - ", value=u'cryptography.io')>, , value=u'PyCA')>" - "])>" - ) + if six.PY3: + assert repr(name) == ( + ", value='cryptography.io')>, , valu" + "e='PyCA')>])>" + ) + else: + assert repr(name) == ( + ", value=u'cryptography.io')>, , val" + "ue=u'PyCA')>])>" + ) diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index de8aea98..d836164b 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -633,7 +633,7 @@ class TestAuthorityKeyIdentifier(object): assert repr(aki) == ( ", value=u'myC" + ", value='myC" "N')>])>)>], authority_cert_serial_number=1234)>" ) else: @@ -1050,10 +1050,18 @@ class TestDirectoryName(object): def test_repr(self): name = x509.Name([x509.NameAttribute(x509.OID_COMMON_NAME, u'value1')]) gn = x509.DirectoryName(x509.Name([name])) - assert repr(gn) == ( - ", value=u'value1')>])>])>)>" - ) + if six.PY3: + assert repr(gn) == ( + ", value='value1')>])" + ">])>)>" + ) + else: + assert repr(gn) == ( + ", value=u'value1')>]" + ")>])>)>" + ) def test_eq(self): name = x509.Name([ @@ -2017,10 +2025,10 @@ class TestDistributionPoint(object): assert repr(dp) == ( ", value=u'myCN')>])>, reasons=frozenset({}), crl_issuer=[, value=u'Important CA')>])>)>])>" + ">, value='myCN')>])>, reasons=frozenset({}), crl_issuer=[, value='Important CA')>])>)>])>" ) else: assert repr(dp) == ( -- cgit v1.2.3