black/tests/data/string_prefixes.py
Richard Si 00e7e12a3a
Regression fix: leave R prefixes capitalization alone (#2285)
`black.strings.get_string_prefix` used to lowercase the extracted
prefix before returning it. This is wrong because 1) it ignores the
fact we should leave R prefixes alone because of MagicPython, and 2)
there is dedicated prefix casing handling code that fixes issue 1.
`.lower` is too naive.

This was originally fixed in 20.8b0, but was reintroduced since 21.4b0.

I also added proper prefix normalization for docstrings by using the
`black.strings.normalize_string_prefix` helper.

Some more test strings were added to make sure strings with capitalized
prefixes aren't treated differently (actually happened with my original
patch, Jelle had to point it out to me).
2021-06-08 17:46:09 -07:00

40 lines
607 B
Python

#!/usr/bin/env python3.6
name = R"Łukasz"
F"hello {name}"
B"hello"
r"hello"
fR"hello"
def docstring_singleline():
R"""2020 was one hell of a year. The good news is that we were able to"""
def docstring_multiline():
R"""
clear out all of the issues opened in that time :p
"""
# output
#!/usr/bin/env python3.6
name = R"Łukasz"
f"hello {name}"
b"hello"
r"hello"
fR"hello"
def docstring_singleline():
R"""2020 was one hell of a year. The good news is that we were able to"""
def docstring_multiline():
R"""
clear out all of the issues opened in that time :p
"""