mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-90633: Improve error and docs for typing.assert_never (#91720)
Closes #90633 Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
9ff2f12c87
commit
93d280141c
4 changed files with 37 additions and 2 deletions
|
@ -223,6 +223,19 @@ class AssertNeverTests(BaseTestCase):
|
|||
with self.assertRaises(AssertionError):
|
||||
assert_never(None)
|
||||
|
||||
value = "some value"
|
||||
with self.assertRaisesRegex(AssertionError, value):
|
||||
assert_never(value)
|
||||
|
||||
# Make sure a huge value doesn't get printed in its entirety
|
||||
huge_value = "a" * 10000
|
||||
with self.assertRaises(AssertionError) as cm:
|
||||
assert_never(huge_value)
|
||||
self.assertLess(
|
||||
len(cm.exception.args[0]),
|
||||
typing._ASSERT_NEVER_REPR_MAX_LENGTH * 2,
|
||||
)
|
||||
|
||||
|
||||
class SelfTests(BaseTestCase):
|
||||
def test_equality(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue