Commit 11a58016 authored by Boxiang Sun's avatar Boxiang Sun

slapos/tests: Refine the assertRegex calling

Python 3.12 completely drops assertRegex.
Also this code keep the Python 2 compatibility.
parent dacc18a8
......@@ -38,6 +38,11 @@ import unittest
import zc.lockfile
import socket
import OpenSSL.SSL
try:
from configparser import ConfigParser
except ImportError:
# BBB python2
unittest.TestCase.assertRegex = unittest.TestCase.assertRegexpMatches
from cryptography import x509
from cryptography.hazmat.backends import default_backend
......@@ -357,12 +362,12 @@ ez+ONyvetfvjD8cxyQ==
httplib.CREATED
)
location = result.headers.get('Location', '')
self.assertRegexpMatches(
self.assertRegex(
location,
r'^/[a-z0-9]{32}$'
)
reserved_reference = result.text
self.assertRegexpMatches(
self.assertRegex(
reserved_reference,
r'^[a-z0-9]{32}$'
)
......@@ -954,7 +959,7 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase):
def test_GET_generateauth(self):
auth = self.generateauth()
self.assertRegexpMatches(
self.assertRegex(
auth,
r'^[a-z0-9]{32}$'
)
......@@ -999,7 +1004,7 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase):
'',
result.text
)
self.assertRegexpMatches(
self.assertRegex(
result.headers.get('Location', ''),
r'^/%s/\d+$' % key
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment