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

Method test_debug_specifier

Lib/test/test_tstring.py:114–141  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

112 eval("t'{num!z}'")
113
114 def test_debug_specifier(self):
115 # Test debug specifier
116 value = 42
117 t = t"Value: {value=}"
118 self.assertTStringEqual(
119 t, ("Value: value=", ""), [(value, "value", "r")]
120 )
121 self.assertEqual(fstring(t), "Value: value=42")
122
123 # Test debug specifier with format (conversion default to !r)
124 t = t"Value: {value=:.2f}"
125 self.assertTStringEqual(
126 t, ("Value: value=", ""), [(value, "value", None, ".2f")]
127 )
128 self.assertEqual(fstring(t), "Value: value=42.00")
129
130 # Test debug specifier with conversion
131 t = t"Value: {value=!s}"
132 self.assertTStringEqual(
133 t, ("Value: value=", ""), [(value, "value", "s")]
134 )
135
136 # Test white space in debug specifier
137 t = t"Value: {value = }"
138 self.assertTStringEqual(
139 t, ("Value: value = ", ""), [(value, "value", "r")]
140 )
141 self.assertEqual(fstring(t), "Value: value = 42")
142
143 def test_raw_tstrings(self):
144 path = r"C:\Users"

Callers

nothing calls this directly

Calls 3

fstringFunction · 0.90
assertTStringEqualMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected