wbond / certvalidator

Python library for validating X.509 certificates and paths
MIT License
107 stars 32 forks source link

updated 'assertRaisesRegexp ' obsolete #46

Open Nilsonfsilva opened 9 months ago

Nilsonfsilva commented 9 months ago

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:

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

-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)

@@ -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' )