patch 73eaf41fff7c150012448f8113ca45623bb5aa23
   "Use textwrap.dedent instead of g.adjustTripleString everywhere"
   in v6.4b2 breaks "newline-and-indent" unit test.

The problem is that textwrap.dedent clears empty lines and the test needs to insert an indented blank line in order to work. Attached patch fixes the problem by disabling textwrap.dedent for the affected test.


Error messages:
Test case for newline-and-indent ... mismatch in body
expected:
[
     'first line\n',
     'line 1\n',
     '\n',
     '    line a\n',
     '        line b\n',
     'line c\n',
     'last line\n'
]
got:
[
     'first line\n',
     'line 1\n',
     '    \n',
     '    line a\n',
     '        line b\n',
     'line c\n',
     'last line\n'
]
parent_p.b ''
FAIL

Traceback (most recent call last):
File "leo/unittests/commands/test_editCommands.py", line 2498, in test_newline_and_indent
     self.run_test(
   File "leo/unittests/commands/test_editCommands.py", line 53, in run_test
     assert False
AssertionError

--
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/28b940cc-4bb7-965e-29ad-1edd5a0c4e85%40runbox.com.
diff --git a/leo/unittests/commands/test_editCommands.py b/leo/unittests/commands/test_editCommands.py
index d9ccff847..2ce0b75bd 100644
--- a/leo/unittests/commands/test_editCommands.py
+++ b/leo/unittests/commands/test_editCommands.py
@@ -18,7 +18,8 @@ class EditCommandsTest(unittest.TestCase):
             before_b, after_b,  # before/after body text.
             before_sel, after_sel,  # before and after selection ranges.
             command_name,
-            directives=''
+            directives='',
+            dedent=True
         ):
         c = self.c
         # For shortDescription().
@@ -27,9 +28,12 @@ class EditCommandsTest(unittest.TestCase):
         command = c.commandsDict.get(command_name)
         assert command, f"no command: {command_name}"
         # Set the text.
-        parent_b = textwrap.dedent(directives)
-        before_b = textwrap.dedent(before_b)
-        after_b = textwrap.dedent(after_b)
+        if dedent:
+            parent_b = textwrap.dedent(directives)
+            before_b = textwrap.dedent(before_b)
+            after_b = textwrap.dedent(after_b)
+        else:
+            parent_b = directives
         self.parent_p.b = parent_b
         self.tempNode.b = before_b
         self.before_p.b = before_b
@@ -2498,9 +2502,10 @@ class EditCommandsTest(unittest.TestCase):
         self.run_test(
             before_b=before_b,
             after_b=after_b,
-            before_sel=("2.6", "2.6"),
-            after_sel=("3.4", "3.4"),
+            before_sel=("2.10", "2.10"),
+            after_sel=("3.8", "3.8"),
             command_name="newline-and-indent",
+            dedent=False
         )
     #@+node:ekr.20201130090918.92: *3* next-line
     def test_next_line(self):

Reply via email to