Skip to content

Commit

Permalink
Loosen message test in test_invalid_input (#751)
Browse files Browse the repository at this point in the history
In test_invalid_input, also accept “(str object cannot be interpreted as an integer)” wherever we expected “an integer is required”; required for Python 3.10 compatibility
  • Loading branch information
musicinmybrain authored Apr 26, 2021
1 parent 6cfdb3a commit bc4127f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ async def test_unhandled_type_fallback(self):
''')

async def test_invalid_input(self):
# The latter message appears beginning in Python 3.10.
integer_required = (
r"(an integer is required|"
r"\('str' object cannot be interpreted as an integer\))")

cases = [
('bytea', 'a bytes-like object is required', [
1,
Expand All @@ -678,7 +683,7 @@ async def test_invalid_input(self):
('bool', 'a boolean is required', [
1,
]),
('int2', 'an integer is required', [
('int2', integer_required, [
'2',
'aa',
]),
Expand All @@ -694,7 +699,7 @@ async def test_invalid_input(self):
4.1 * 10 ** 40,
-4.1 * 10 ** 40,
]),
('int4', 'an integer is required', [
('int4', integer_required, [
'2',
'aa',
]),
Expand All @@ -705,7 +710,7 @@ async def test_invalid_input(self):
2**31,
-2**31 - 1,
]),
('int8', 'an integer is required', [
('int8', integer_required, [
'2',
'aa',
]),
Expand Down

0 comments on commit bc4127f

Please sign in to comment.