MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_missing_expression

Method test_missing_expression

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

Source from the content-addressed store, hash-verified

873
874 @unittest.expectedFailure # TODO: RUSTPYTHON
875 def test_missing_expression(self):
876 self.assertAllRaise(SyntaxError,
877 "f-string: valid expression required before '}'",
878 ["f'{}'",
879 "f'{ }'"
880 "f' {} '",
881 "f'{10:{ }}'",
882 "f' { } '",
883
884 # The Python parser ignores also the following
885 # whitespace characters in additional to a space.
886 "f'''{\t\f\r\n}'''",
887 ])
888
889 self.assertAllRaise(SyntaxError,
890 "f-string: valid expression required before '!'",
891 ["f'{!r}'",
892 "f'{ !r}'",
893 "f'{!}'",
894 "f'''{\t\f\r\n!a}'''",
895
896 # Catch empty expression before the
897 # missing closing brace.
898 "f'{!'",
899 "f'{!s:'",
900
901 # Catch empty expression before the
902 # invalid conversion.
903 "f'{!x}'",
904 "f'{ !xr}'",
905 "f'{!x:}'",
906 "f'{!x:a}'",
907 "f'{ !xr:}'",
908 "f'{ !xr:a}'",
909 ])
910
911 self.assertAllRaise(SyntaxError,
912 "f-string: valid expression required before ':'",
913 ["f'{:}'",
914 "f'{ :!}'",
915 "f'{:2}'",
916 "f'''{\t\f\r\n:a}'''",
917 "f'{:'",
918 "F'{[F'{:'}[F'{:'}]]]",
919 ])
920
921 self.assertAllRaise(SyntaxError,
922 "f-string: valid expression required before '='",
923 ["f'{=}'",
924 "f'{ =}'",
925 "f'{ =:}'",
926 "f'{ =!}'",
927 "f'''{\t\f\r\n=}'''",
928 "f'{='",
929 ])
930
931 # Different error message is raised for other whitespace characters.
932 self.assertAllRaise(SyntaxError, r"invalid non-printable character U\+00A0",

Callers

nothing calls this directly

Calls 1

assertAllRaiseMethod · 0.95

Tested by

no test coverage detected