summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-09-18 17:20:08 +0200
committerTomas Babej <tbabej@redhat.com>2015-10-13 14:16:32 +0200
commit929c3d1265dcb7af375d433a7e0b44193e19ed2f (patch)
treec7a7fe7b9d6cc0c0237b51acda513778ee25efcc /ipatests
parent59d87d53b10a201ef03077c96011523bdd1342e8 (diff)
downloadfreeipa-929c3d1265dcb7af375d433a7e0b44193e19ed2f.tar.gz
freeipa-929c3d1265dcb7af375d433a7e0b44193e19ed2f.tar.xz
freeipa-929c3d1265dcb7af375d433a7e0b44193e19ed2f.zip
x509: Port to Python 3
In python 3 , `bytes` has the buffer interface, and `buffer` was removed. Also, invalid padding in base64-encoded data raises a ValueError rather than TypeError. In tests, use pytest.assert_raises for more correct exception assertions. Also, get rid of unused imports in the tests Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_ipalib/test_x509.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/ipatests/test_ipalib/test_x509.py b/ipatests/test_ipalib/test_x509.py
index c7fafbbd9..d8004c4a0 100644
--- a/ipatests/test_ipalib/test_x509.py
+++ b/ipatests/test_ipalib/test_x509.py
@@ -21,17 +21,12 @@
Test the `ipalib.x509` module.
"""
-import os
-from os import path
-import sys
-from ipatests.util import raises, setitem, delitem, ClassChecker
-from ipatests.util import getitem, setitem, delitem
-from ipatests.util import TempDir, TempHome
-from ipalib.constants import TYPE_ERROR, OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
-from ipalib.constants import NAME_REGEX, NAME_ERROR
import base64
-from ipalib import x509
+
+import pytest
from nss.error import NSPRError
+
+from ipalib import x509
from ipapython.dn import DN
# certutil -
@@ -66,16 +61,12 @@ class test_x509(object):
# Load a good cert with bad headers
newcert = '-----BEGIN CERTIFICATE-----' + goodcert
- try:
+ with pytest.raises((TypeError, ValueError)):
cert = x509.load_certificate(newcert)
- except TypeError:
- pass
# Load a bad cert
- try:
+ with pytest.raises(NSPRError):
cert = x509.load_certificate(badcert)
- except NSPRError:
- pass
def test_1_load_der_cert(self):
"""