updated 'assertRaisesRegexp ' obsolete

オープン 初心者向け
#46 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
testing-qa

調査の方向性

まず tests/_unittest_compat.py から始め、指定された test_certificate_validator.py と test_validate.py ファイルで assertRaisesRegexp の参照を検索します。Python 3.12 でテストスイートを実行し、廃止された API 参照が削除され、影響を受けるテストが正常に実行されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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)
    
主要言語
Python
スター
117
フォーク
37
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wbond/certvalidator のほかの issue

wbond/certvalidator の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。