summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_format.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2025-02-25 15:27:07 (GMT)
committerGitHub <noreply@github.com>2025-02-25 15:27:07 (GMT)
commitf39a07be47cd9219eaf0e538ae32ad8239c88e66 (patch)
tree1b57568378401b44c9ffd8d3f237b13694842b5c /Lib/test/test_format.py
parentfa6a8140dd2a72da6df2a7dfafbf07045debf64d (diff)
downloadcpython-f39a07be47cd9219eaf0e538ae32ad8239c88e66.zip
cpython-f39a07be47cd9219eaf0e538ae32ad8239c88e66.tar.gz
cpython-f39a07be47cd9219eaf0e538ae32ad8239c88e66.tar.bz2
gh-87790: support thousands separators for formatting fractional part of floats (#125304)
```pycon >>> f"{123_456.123_456:_._f}" # Whole and fractional '123_456.123_456' >>> f"{123_456.123_456:_f}" # Integer component only '123_456.123456' >>> f"{123_456.123_456:._f}" # Fractional component only '123456.123_456' >>> f"{123_456.123_456:.4_f}" # with precision '123456.1_235' ```
Diffstat (limited to 'Lib/test/test_format.py')
-rw-r--r--Lib/test/test_format.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 9dde63e..3916bc3 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -515,11 +515,15 @@ class FormatTest(unittest.TestCase):
error_msg = re.escape("Cannot specify both ',' and '_'.")
with self.assertRaisesRegex(ValueError, error_msg):
'{:,_}'.format(1)
+ with self.assertRaisesRegex(ValueError, error_msg):
+ '{:.,_f}'.format(1.1)
def test_with_an_underscore_and_a_comma_in_format_specifier(self):
error_msg = re.escape("Cannot specify both ',' and '_'.")
with self.assertRaisesRegex(ValueError, error_msg):
'{:_,}'.format(1)
+ with self.assertRaisesRegex(ValueError, error_msg):
+ '{:._,f}'.format(1.1)
def test_better_error_message_format(self):
# https://bugs.python.org/issue20524