MCPcopy Create free account
hub / github.com/astral-sh/ruff / test_parse_invalid_fstring

Function test_parse_invalid_fstring

crates/ruff_python_parser/src/string.rs:636–651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

634
635 #[test]
636 fn test_parse_invalid_fstring() {
637 use InterpolatedStringErrorType::{InvalidConversionFlag, LambdaWithoutParentheses};
638
639 assert_eq!(parse_fstring_error(r#"f"{5!x}""#), InvalidConversionFlag);
640 assert_eq!(
641 parse_fstring_error("f'{lambda x:{x}}'"),
642 LambdaWithoutParentheses
643 );
644 // NOTE: The parser produces the `LambdaWithoutParentheses` for this case, but
645 // since the parser only return the first error to maintain compatibility with
646 // the rest of the codebase, this test case fails. The `LambdaWithoutParentheses`
647 // error appears after the unexpected `FStringMiddle` token, which is between the
648 // `:` and the `{`.
649 // assert_eq!(parse_fstring_error("f'{lambda x: {x}}'"), LambdaWithoutParentheses);
650 assert!(parse_suite(r#"f"{class}""#).is_err());
651 }
652
653 #[test]
654 fn test_parse_fstring_not_equals() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected