MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_invalid_indent

Method test_invalid_indent

Lib/test/test_reprlib.py:591–608  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

589 self.assertEqual(resulting_repr, expected_repr)
590
591 def test_invalid_indent(self):
592 test_object = [1, 'spam', {'eggs': True, 'ham': []}]
593 test_cases = [
594 (-1, (ValueError, '[Nn]egative|[Pp]ositive')),
595 (-4, (ValueError, '[Nn]egative|[Pp]ositive')),
596 ((), (TypeError, None)),
597 ([], (TypeError, None)),
598 ((4,), (TypeError, None)),
599 ([4,], (TypeError, None)),
600 (object(), (TypeError, None)),
601 ]
602 for indent, (expected_error, expected_msg) in test_cases:
603 with self.subTest(indent=indent):
604 r = Repr()
605 r.indent = indent
606 expected_msg = expected_msg or f'{type(indent)}'
607 with self.assertRaisesRegex(expected_error, expected_msg):
608 r.repr(test_object)
609
610 def test_shadowed_stdlib_array(self):
611 # Issue #113570: repr() should not be fooled by an array

Callers

nothing calls this directly

Calls 4

reprMethod · 0.95
ReprClass · 0.90
subTestMethod · 0.80
assertRaisesRegexMethod · 0.80

Tested by

no test coverage detected