Repository: nose-devs/nose2

Issue:
Layer-reporter does not indent docstring 
Given a test
def test_mymethond(self):
    """what this does

   hi there
   """

nose2 will output 'what this does' when the test is run, but the text will not be indented to reflect the layers used. 

Result of test run: 
TopLayer
&nbsp;&nbsp;SecondLayer
&nbsp;&nbsp;&nbsp;&nbsp;test_find_unassigned_signals (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_no_newer_definitions (test_wrapper.SecondLayerTests)
Test that versions in API Wrapper are the latest ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_add_customer_once (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_one_parquet_file_pr_customer (test_wrapper.SecondLayerTests) ... ok

Expected:
TopLayer
&nbsp;&nbsp;SecondLayer
&nbsp;&nbsp;&nbsp;&nbsp;test_find_unassigned_signals (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_no_newer_definitions (test_wrapper.SecondLayerTests)
&nbsp;&nbsp;&nbsp;&nbsp;Test that versions in API Wrapper are the latest ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_add_customer_once (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_one_parquet_file_pr_customer (test_wrapper.SecondLayerTests) ... ok

or maybe even
TopLayer
&nbsp;&nbsp;SecondLayer
&nbsp;&nbsp;&nbsp;&nbsp;test_find_unassigned_signals (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;Test that versions in API Wrapper are the latest (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_add_customer_once (test_wrapper.SecondLayerTests) ... ok
&nbsp;&nbsp;&nbsp;&nbsp;test_only_one_parquet_file_pr_customer (test_wrapper.SecondLayerTests) ... ok

Comments:

Patch:
diff --git a/nose2/plugins/layers.py b/nose2/plugins/layers.py
index 43025ca..eda14dc 100644
--- a/nose2/plugins/layers.py
+++ b/nose2/plugins/layers.py
@@ -235,6 +235,9 @@ class LayerReporter(events.Plugin):
         if event.errorList and hasattr(event.test, 'layer'):
             # walk back layers to build full description
             self.describeLayers(event)
+        # we need to remove "\n" from description to keep a well indented report when tests have docstrings
+        # see https://github.com/nose-devs/nose2/issues/327 for more information
+        event.description = event.description.replace('\n', ' ')
 
     def describeLayers(self, event):
         desc = [event.description]


Test patch:
diff --git a/nose2/tests/functional/support/scenario/layers/test_layers.py b/nose2/tests/functional/support/scenario/layers/test_layers.py
index e800780..a35bb0f 100644
--- a/nose2/tests/functional/support/scenario/layers/test_layers.py
+++ b/nose2/tests/functional/support/scenario/layers/test_layers.py
@@ -180,6 +180,8 @@ class InnerD(unittest.TestCase):
     layer = LayerD
 
     def test(self):
+        """test with docstring
+        """
         self.assertEqual(
             {'base': 'setup',
              'layerD': 'setup'},
diff --git a/nose2/tests/functional/test_layers_plugin.py b/nose2/tests/functional/test_layers_plugin.py
index 9666dba..c658bbe 100644
--- a/nose2/tests/functional/test_layers_plugin.py
+++ b/nose2/tests/functional/test_layers_plugin.py
@@ -56,7 +56,7 @@ class TestLayers(FunctionalTestCase):
 Base
   test \(test_layers.Outer\) ... ok
   LayerD
-    test \(test_layers.InnerD\) ... ok
+    test \(test_layers.InnerD\) test with docstring ... ok
   LayerA
     test \(test_layers.InnerA\) ... ok
   LayerB