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

Discussion:
coveralls: 
[![Coverage Status](https://coveralls.io/builds/14177954/badge)](https://coveralls.io/builds/14177954)

Coverage increased (+0.003%) to 87.456% when pulling **9dbc760a4ebbee8a5e5c5201446966b012b5d80d on artragis:fix_327** into **862b130652b9118eb8d5681923c04edb000245d3 on nose-devs:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/14177954/badge)](https://coveralls.io/builds/14177954)

Coverage increased (+0.003%) to 87.456% when pulling **9dbc760a4ebbee8a5e5c5201446966b012b5d80d on artragis:fix_327** into **862b130652b9118eb8d5681923c04edb000245d3 on nose-devs:master**.

katrinabrock: Did adding a docstring to the test actually cause it to fail? If not, please write a test that fails in mainline to demonstrate the issue.
artragis: > Did adding a docstring to the test actually cause it  to fail? If not, please write a test that fails in mainline to  demonstrate the issue.

Yes it did. That's why I had to change the "expected" text 



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