Esempio n. 1
0
 def test_format_disallow_invalid_type(self):
     with self.assertRaisesRegex(ValueError, "Unknown format code 'T'"):
         types.NumberFormatter("{:T}")
Esempio n. 2
0
 def test_format_disallow_field_converter(self):
     with self.assertRaisesRegex(ValueError, "Field converters are not allowed"):
         types.NumberFormatter("{!r:f}")
Esempio n. 3
0
 def test_format_disallow_non_format(self):
     with self.assertRaisesRegex(ValueError, 'Format must look like "{:...}"'):
         types.NumberFormatter("%d")
Esempio n. 4
0
 def test_format_disallow_field_name(self):
     with self.assertRaisesRegex(
         ValueError, "Field names or numbers are not allowed"
     ):
         types.NumberFormatter("{value:f}")
Esempio n. 5
0
 def test_format_too_many_arguments(self):
     with self.assertRaisesRegex(ValueError, "Can only format one number"):
         types.NumberFormatter("{:d}{:f}")