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

Function test_parse_invalid_tstring

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

Source from the content-addressed store, hash-verified

751
752 #[test]
753 fn test_parse_invalid_tstring() {
754 use InterpolatedStringErrorType::{InvalidConversionFlag, LambdaWithoutParentheses};
755
756 assert_eq!(parse_tstring_error(r#"t"{5!x}""#), InvalidConversionFlag);
757 assert_eq!(
758 parse_tstring_error("t'{lambda x:{x}}'"),
759 LambdaWithoutParentheses
760 );
761 // NOTE: The parser produces the `LambdaWithoutParentheses` for this case, but
762 // since the parser only return the first error to maintain compatibility with
763 // the rest of the codebase, this test case fails. The `LambdaWithoutParentheses`
764 // error appears after the unexpected `tStringMiddle` token, which is between the
765 // `:` and the `{`.
766 // assert_eq!(parse_tstring_error("f'{lambda x: {x}}'"), LambdaWithoutParentheses);
767 assert!(parse_suite(r#"t"{class}""#).is_err());
768 }
769
770 #[test]
771 fn test_parse_tstring_not_equals() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected