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

Method test_ast_fstring_empty_format_spec

Lib/test/test_fstring.py:501–517  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

499 self.assertEqual(fstring.end_col_offset, 18)
500
501 def test_ast_fstring_empty_format_spec(self):
502 expr = "f'{expr:}'"
503
504 mod = ast.parse(expr)
505 self.assertEqual(type(mod), ast.Module)
506 self.assertEqual(len(mod.body), 1)
507
508 fstring = mod.body[0].value
509 self.assertEqual(type(fstring), ast.JoinedStr)
510 self.assertEqual(len(fstring.values), 1)
511
512 fv = fstring.values[0]
513 self.assertEqual(type(fv), ast.FormattedValue)
514
515 format_spec = fv.format_spec
516 self.assertEqual(type(format_spec), ast.JoinedStr)
517 self.assertEqual(len(format_spec.values), 0)
518
519 def test_ast_fstring_format_spec(self):
520 expr = "f'{1:{name}}'"

Callers

nothing calls this directly

Calls 2

assertEqualMethod · 0.95
parseMethod · 0.45

Tested by

no test coverage detected