From 1625b84e33c895b32f386f2628392fe4bee65d8a Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Thu, 21 Sep 2017 20:33:42 +0300 Subject: [PATCH] PY-17017 PY-15051 Add a test on handling trailing block comments in formatter --- .../trailingBlockCommentsIndentationPreserved.py | 10 ++++++++++ .../trailingBlockCommentsIndentationPreserved_after.py | 10 ++++++++++ .../testSrc/com/jetbrains/python/PyFormatterTest.java | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 python/testData/formatter/trailingBlockCommentsIndentationPreserved.py create mode 100644 python/testData/formatter/trailingBlockCommentsIndentationPreserved_after.py diff --git a/python/testData/formatter/trailingBlockCommentsIndentationPreserved.py b/python/testData/formatter/trailingBlockCommentsIndentationPreserved.py new file mode 100644 index 000000000000..81759d319cf4 --- /dev/null +++ b/python/testData/formatter/trailingBlockCommentsIndentationPreserved.py @@ -0,0 +1,10 @@ +class C: + def method(self): + def foo(): + def bar(): + pass + # bar + # bar + # bar + # method + # class diff --git a/python/testData/formatter/trailingBlockCommentsIndentationPreserved_after.py b/python/testData/formatter/trailingBlockCommentsIndentationPreserved_after.py new file mode 100644 index 000000000000..20f0373a2afe --- /dev/null +++ b/python/testData/formatter/trailingBlockCommentsIndentationPreserved_after.py @@ -0,0 +1,10 @@ +class C: + def method(self): + def foo(): + def bar(): + pass + # bar + # bar + # bar + # method + # class diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 9c4b0fa6a8c6..6b873248bf66 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -852,6 +852,11 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + // PY-15051 + public void testTrailingBlockCommentsIndentationPreserved() { + doTest(); + } + public void testVariableAnnotations() { runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest); }