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

Method test_format_errors

Lib/test/test_peepholer.py:742–771  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

740
741 @unittest.expectedFailure # TODO: RUSTPYTHON; ValueError: unsupported format character 'z' (0x7a) at index 3
742 def test_format_errors(self):
743 with self.assertRaisesRegex(TypeError,
744 'not enough arguments for format string'):
745 eval("'%s' % ()")
746 with self.assertRaisesRegex(TypeError,
747 'not all arguments converted during string formatting'):
748 eval("'%s' % (x, y)", {'x': 1, 'y': 2})
749 with self.assertRaisesRegex(ValueError, 'incomplete format'):
750 eval("'%s%' % (x,)", {'x': 1234})
751 with self.assertRaisesRegex(ValueError, 'incomplete format'):
752 eval("'%s%%%' % (x,)", {'x': 1234})
753 with self.assertRaisesRegex(TypeError,
754 'not enough arguments for format string'):
755 eval("'%s%z' % (x,)", {'x': 1234})
756 with self.assertRaisesRegex(ValueError, 'unsupported format character'):
757 eval("'%s%z' % (x, 5)", {'x': 1234})
758 with self.assertRaisesRegex(TypeError, 'a real number is required, not str'):
759 eval("'%d' % (x,)", {'x': '1234'})
760 with self.assertRaisesRegex(TypeError, 'an integer is required, not float'):
761 eval("'%x' % (x,)", {'x': 1234.56})
762 with self.assertRaisesRegex(TypeError, 'an integer is required, not str'):
763 eval("'%x' % (x,)", {'x': '1234'})
764 with self.assertRaisesRegex(TypeError, 'must be real number, not str'):
765 eval("'%f' % (x,)", {'x': '1234'})
766 with self.assertRaisesRegex(TypeError,
767 'not enough arguments for format string'):
768 eval("'%s, %s' % (x, *y)", {'x': 1, 'y': []})
769 with self.assertRaisesRegex(TypeError,
770 'not all arguments converted during string formatting'):
771 eval("'%s, %s' % (x, *y)", {'x': 1, 'y': [2, 3]})
772
773 def test_static_swaps_unpack_two(self):
774 def f(a, b):

Callers

nothing calls this directly

Calls 2

assertRaisesRegexMethod · 0.80
evalFunction · 0.50

Tested by

no test coverage detected