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