Description
Hey!
I am the maintainer of your project on Debian.
We recently migrated to python 3.12.
And some tests failed. I had to make a patch to run some tests:
- unittest.TestCase.assertRaisesRegexp = _assert_raises_regexp
- unittest.TestCase.assertRaisesRegex = _assert_raises_regex
following patch:
Index: python-certvalidator/tests/_unittest_compat.py
--- python-certvalidator.orig/tests/_unittest_compat.py
+++ python-certvalidator/tests/_unittest_compat.py
@@ -4,7 +4,7 @@ from future import unicode_literals,
import sys
import unittest
import re
+import pytest
_non_local = {'patched': False}
@@ -18,7 +18,7 @@ def patch():
unittest.TestCase.assertIsInstance = _assert_is_instance
unittest.TestCase.assertRaises = _assert_raises
- unittest.TestCase.assertRaisesRegexp = _assert_raises_regexp
- unittest.TestCase.assertRaisesRegex = _assert_raises_regex
unittest.TestCase.assertLess = _assert_less
unittest.TestCase.assertIn = _assert_in
_non_local['patched'] = True
@@ -51,7 +51,7 @@ def _assert_raises(self, excClass, calla
callableObj(*args, **kwargs)
-def _assert_raises_regexp(self, expected_exception, expected_regexp, callable_obj=None, *args>
+def _assert_raises_regex(self, expected_exception, expected_regexp, callable_obj=None, *args,>
if expected_regexp is not None:
expected_regexp = re.compile(expected_regexp)
context = _AssertRaisesContext(expected_exception, self, expected_regexp)
Index: python-certvalidator/tests/test_certificate_validator.py
--- python-certvalidator.orig/tests/test_certificate_validator.py
+++ python-certvalidator/tests/test_certificate_validator.py
@@ -1,9 +1,11 @@
+#!/usr/bin/env python3
coding: utf-8
from future import unicode_literals, division, absolute_import, print_function
from datetime import datetime
import unittest
import os
+import pytest
from asn1crypto import pem, x509
from asn1crypto.util import timezone
@@ -52,7 +54,7 @@ class CertificateValidatorTests(unittest
validator = CertificateValidator(cert, other_certs)
-
with self.assertRaisesRegexp(PathValidationError, 'expired'):
-
with self.assertRaisesRegex(PathValidationError, 'expired'): validator.validate_tls('codexns.io')
@unittest.skip("Not running tests")
@@ -65,7 +67,7 @@ class CertificateValidatorTests(unittest
context = ValidationContext(moment=moment)
validator = CertificateValidator(cert, other_certs, context)
-
with self.assertRaisesRegexp(PathValidationError, 'not valid'):
-
with self.assertRaisesRegex(PathValidationError, 'not valid'): validator.validate_tls('google.com')
@unittest.skip("Not running tests")
@@ -78,7 +80,7 @@ class CertificateValidatorTests(unittest
context = ValidationContext(moment=moment)
validator = CertificateValidator(cert, other_certs, context)
-
with self.assertRaisesRegexp(PathValidationError, 'for the purpose'):
-
with self.assertRaisesRegex(PathValidationError, 'for the purpose'): validator.validate_usage(set(['crl_sign']))
@unittest.skip("Not running tests")
Index: python-certvalidator/tests/test_validate.py
===================================================================
--- python-certvalidator.orig/tests/test_validate.py
+++ python-certvalidator/tests/test_validate.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
coding: utf-8
from future import unicode_literals, division, absolute_import, print_function
@@ -6,6 +7,7 @@ import base64
import unittest
import os
import sys
+import pytest
from asn1crypto import crl, ocsp, pem, x509
from asn1crypto.util import timezone
@@ -113,7 +115,7 @@ class ValidateTests(unittest.TestCase):
'(CRL|OCSP response) indicates the end-entity certificate was '
'revoked at 15:44:10 on 2014-04-23, due to an unspecified reason'
)
-
with self.assertRaisesRegexp(RevokedError, expected):
-
with self.assertRaisesRegex(RevokedError, expected): validate_path(context, path)
@DaTa('ocsp_info', True)
@@ -135,7 +137,7 @@ class ValidateTests(unittest.TestCase):
self.assertEqual(path_len, len(path))if excp_class:
-
with self.assertRaisesRegexp(excp_class, excp_msg):
-
with self.assertRaisesRegex(excp_class, excp_msg): validate_path(context, path) else: validate_path(context, path)
@@ -684,7 +686,7 @@ class ValidateTests(unittest.TestCase):
'The path could not be validated because the end-entity certificate '
'issuer name could not be matched'
)
-
with self.assertRaisesRegexp(PathValidationError, expected):
-
with self.assertRaisesRegex(PathValidationError, expected): validate_path(context, path)
def test_nist_40302_invalid_name_chaining_order_test2(self):
@@ -716,7 +718,7 @@ class ValidateTests(unittest.TestCase):
'The path could not be validated because the end-entity certificate '
'issuer name could not be matched'
)
-
with self.assertRaisesRegexp(PathValidationError, expected):
-
with self.assertRaisesRegex(PathValidationError, expected): validate_path(context, path)
@DaTa('nist_info', True)
@@ -742,7 +744,7 @@ class ValidateTests(unittest.TestCase):
self.assertEqual(path_len, len(path))if excp_class:
-
with self.assertRaisesRegexp(excp_class, excp_msg):
-
with self.assertRaisesRegex(excp_class, excp_msg): validate_path(context, path) else: validate_path(context, path)