From eaa337f176b086a9ebd91884c0b9d9a96772aeb3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Mon, 26 Apr 2021 20:24:06 +0200 Subject: [PATCH] Add more tests for fancy whitespace (#2147) --- CHANGES.md | 2 + tests/data/docstring.py | 28 +++++++++++++ .../data/docstring_no_string_normalization.py | 40 +++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 814956c..a3bf556 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,8 @@ - Fix crash on docstrings ending with "\ ". (#2142) +- Fix crash when atypical whitespace is cleaned out of dostrings (#2120) + - Reflect the `--skip-magic-trailing-comma` and `--experimental-string-processing` flags in the name of the cache file. Without this fix, changes in these flags would not take effect if the cache had already been populated. (#2131) diff --git a/tests/data/docstring.py b/tests/data/docstring.py index ee6d0c0..e977619 100644 --- a/tests/data/docstring.py +++ b/tests/data/docstring.py @@ -174,6 +174,20 @@ def multiline_backslash_2(): hey there \ ''' +def multiline_backslash_3(): + ''' + already escaped \\ ''' + + +def my_god_its_full_of_stars_1(): + "I'm sorry Dave\u2001" + + +# the space below is actually a \u2001, removed in output +def my_god_its_full_of_stars_2(): + "I'm sorry Dave " + + # output class MyClass: @@ -347,3 +361,17 @@ def multiline_backslash_1(): def multiline_backslash_2(): """ hey there \ """ + + +def multiline_backslash_3(): + """ + already escaped \\""" + + +def my_god_its_full_of_stars_1(): + "I'm sorry Dave\u2001" + + +# the space below is actually a \u2001, removed in output +def my_god_its_full_of_stars_2(): + "I'm sorry Dave" \ No newline at end of file diff --git a/tests/data/docstring_no_string_normalization.py b/tests/data/docstring_no_string_normalization.py index 0457fcf..a90b578 100644 --- a/tests/data/docstring_no_string_normalization.py +++ b/tests/data/docstring_no_string_normalization.py @@ -102,6 +102,26 @@ def shockingly_the_quotes_are_normalized_v2(): ''' pass + +def backslash_space(): + '\ ' + + +def multiline_backslash_1(): + ''' + hey\there\ + \ ''' + + +def multiline_backslash_2(): + ''' + hey there \ ''' + + +def multiline_backslash_3(): + ''' + already escaped \\ ''' + # output class ALonelyClass: @@ -207,3 +227,23 @@ def shockingly_the_quotes_are_normalized_v2(): Docstring Docstring Docstring ''' pass + + +def backslash_space(): + '\ ' + + +def multiline_backslash_1(): + ''' + hey\there\ + \ ''' + + +def multiline_backslash_2(): + ''' + hey there \ ''' + + +def multiline_backslash_3(): + ''' + already escaped \\''' -- 2.39.2