updated 'assertRaisesRegexp ' obsolete
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 115
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/_unittest_compat.py and search the named test_certificate_validator.py and test_validate.py files for assertRaisesRegexp references. Run the test suite with Python 3.12 and confirm the obsolete API references are removed and the affected tests execute successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100