Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated assertRaisesRegexp() in tests for py3.12 #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TestCompile(unittest.TestCase):
def test_raise(self):
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
re2.error,
'no argument for repetition operator: \\*'
):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,28 @@ def test_set_anchor_start(self):
self.assertEqual(s.match('baro'), [1])

def test_bad_anchoring(self):
with self.assertRaisesRegexp(ValueError, 'anchoring must be one of.*'):
with self.assertRaisesRegex(ValueError, 'anchoring must be one of.*'):
re2.Set(None)

with self.assertRaisesRegexp(ValueError, 'anchoring must be one of.*'):
with self.assertRaisesRegex(ValueError, 'anchoring must be one of.*'):
re2.Set(15)

with self.assertRaisesRegexp(ValueError, 'anchoring must be one of.*'):
with self.assertRaisesRegex(ValueError, 'anchoring must be one of.*'):
re2.Set({})

def test_match_without_compile(self):
s = re2.Set()
s.add('foo')

with self.assertRaisesRegexp(RuntimeError, 'Can\'t match\(\) on an.*'):
with self.assertRaisesRegex(RuntimeError, 'Can\'t match\(\) on an.*'):
s.match('bar')

def test_add_after_compile(self):
s = re2.Set()
s.add('foo')
s.compile()

with self.assertRaisesRegexp(RuntimeError,
with self.assertRaisesRegex(RuntimeError,
'Can\'t add\(\) on an already compiled Set'):
s.add('bar')

Expand All @@ -199,7 +199,7 @@ def test_double_compile(self):
def test_add_with_bad_pattern(self):
s = re2.Set()

with self.assertRaisesRegexp(ValueError, 'missing \)'):
with self.assertRaisesRegex(ValueError, 'missing \)'):
s.add('(')

with self.assertRaises(TypeError):
Expand Down