MCPcopy Index your code
hub / github.com/python/cpython / test_specifier_z_error

Method test_specifier_z_error

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

Source from the content-addressed store, hash-verified

769 self.assertEqual(f"{-0.:🖤>z6.1f}", "🖤🖤🖤0.0") # multi-byte fill char
770
771 def test_specifier_z_error(self):
772 error_msg = re.compile("Invalid format specifier '.*z.*'")
773 with self.assertRaisesRegex(ValueError, error_msg):
774 f"{0:z+f}" # wrong position
775 with self.assertRaisesRegex(ValueError, error_msg):
776 f"{0:fz}" # wrong position
777
778 error_msg = re.escape("Negative zero coercion (z) not allowed")
779 with self.assertRaisesRegex(ValueError, error_msg):
780 f"{0:zd}" # can't apply to int presentation type
781 with self.assertRaisesRegex(ValueError, error_msg):
782 f"{'x':zs}" # can't apply to string
783
784 error_msg = re.escape("unsupported format %z at position 0")
785 with self.assertRaisesRegex(ValueError, error_msg):
786 "%z.1f" % 0 # not allowed in old style string interpolation
787 with self.assertRaisesRegex(ValueError, error_msg):
788 b"%z.1f" % 0
789
790
791if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

assertRaisesRegexMethod · 0.80
escapeMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected