diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-09-10 18:28:11 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-09-10 18:28:11 +0200 |
commit | 40d5a7f27b8f56e103cdc83d3a294f02c5eb1496 (patch) | |
tree | 3e3c70258afa606cef690f558a615987ad110ce3 /tests | |
parent | bac135a0ac35acb6ebefa683541fc34b920f7671 (diff) | |
download | pyasn1-git-40d5a7f27b8f56e103cdc83d3a294f02c5eb1496.tar.gz |
Fix failing `OctetString` to unicode conversion tests on Py2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/type/test_univ.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py index 9762959..124e5e9 100644 --- a/tests/type/test_univ.py +++ b/tests/type/test_univ.py @@ -551,7 +551,13 @@ class OctetStringWithAsciiTestCase(OctetStringWithUnicodeMixIn, BaseTestCase): class OctetStringUnicodeErrorTestCase(BaseTestCase): def testEncodeError(self): - text = octs2str(ints2octs((0xff, 0xfe))) + serialized = ints2octs((0xff, 0xfe)) + + if sys.version_info < (3, 0): + text = serialized.decode('iso-8859-1') + + else: + text = octs2str(serialized) try: univ.OctetString(text, encoding='us-ascii') @@ -567,8 +573,14 @@ class OctetStringUnicodeErrorTestCase(BaseTestCase): def testDecodeError(self): serialized = ints2octs((0xff, 0xfe)) + octetString = univ.OctetString(serialized, encoding='us-ascii') + try: - str(univ.OctetString(serialized, encoding='us-ascii')) + if sys.version_info < (3, 0): + unicode(octetString) + + else: + str(octetString) except PyAsn1UnicodeDecodeError: pass |