Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b51ae20

Browse files
committed
Add format-spec string test snippets
1 parent f77e96e commit b51ae20

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

extra_tests/snippets/fstrings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@
4747
spec = "0>+#10x"
4848
assert f"{16:{spec}}{foo}" == '00000+0x10bar'
4949

50+
part_spec = ">+#10x"
51+
assert f"{16:0{part_spec}}{foo}" == '00000+0x10bar'
52+
53+
# TODO: RUSTPYTHON, delete the next block once `test_fstring.py` can successfully parse
54+
assert f'{10:#{1}0x}' == ' 0xa'
55+
assert f'{10:{"#"}1{0}{"x"}}' == ' 0xa'
56+
assert f'{-10:-{"#"}1{0}x}' == ' -0xa'
57+
assert f'{-10:{"-"}#{1}0{"x"}}' == ' -0xa'
58+
5059
# TODO:
5160
# spec = "bla"
5261
# assert_raises(ValueError, lambda: f"{16:{spec}}")

0 commit comments

Comments
 (0)