Repository: twosigma/marbles

Issue:
Dedent note before reformatting
We want to allow users to write notes as triple-quoted multiline strings that are:

1. indented in the source
```python
class MyTestCase(marbles.core.TestCase):

    def test_bar(self):
        note = '''Welcome to your new marbles test suite!
        We're so glad you're here.

        Here are some things you can do:

            1. foo

            2. bar
        '''

        self.assertTrue(False, note=note)
```
2. lined up all the way to the left of the test output 
```bash
marbles.marbles.AnnotatedAssertionError: False is not true

Source:
     38 
 >   39 self.assertTrue(False, note=note)
     40 
Locals:

Note:
	Welcome to your new marbles test suite! We're so glad you're here.

	Here are some things you can do:

	    1. foo

	    2. bar
    

----------------------------------------------------------------------
Ran 1 tests in 0.002s

FAILED (failures=1)
```

Currently, in order to achieve 2, users have to align their multiline strings all the way to the left in the source, or they have to do their own dedenting before passing the note to an assertion.

We can do this dedenting for users by calling [`textwrap.dedent`](https://docs.python.org/3.7/library/textwrap.html#textwrap.dedent) on the note before we do the remaining reformatting.

Comments:

Patch:
diff --git a/marbles/core/marbles/core/marbles.py b/marbles/core/marbles/core/marbles.py
index 750dca9..7d1ae37 100644
--- a/marbles/core/marbles/core/marbles.py
+++ b/marbles/core/marbles/core/marbles.py
@@ -245,7 +245,8 @@ Source ({filename}):
         if self._note is None:
             return None
         else:
-            formatted_note = self._note.format(**self.locals)
+            dedented_note = textwrap.dedent(self._note)
+            formatted_note = dedented_note.format(**self.locals)
             wrapper = _NoteWrapper(width=72,
                                    break_long_words=False,
                                    initial_indent='\t',


Test patch:
diff --git a/marbles/core/tests/test_marbles.py b/marbles/core/tests/test_marbles.py
index e6941f7..a69909b 100644
--- a/marbles/core/tests/test_marbles.py
+++ b/marbles/core/tests/test_marbles.py
@@ -102,91 +102,91 @@ class ExampleTestCaseMixin(
 
     def test_long_note(self):
         note = '''
-Onionskins - Although this cane-cut swirl usually has at its center a
-clear glass core, it appears solidly colored because the clear core is
-covered by a thin layer of opaque color and then covered again by a
-thin layer of clear glass. Extremely popular and highly prized,
-onionskins take their name from the layering of glass, like layers of
-an onion. In contrast to end of day marbles, onion skins have two
-pontils. The base color, usually white or yellow, was applied by
-rolling clear glass marble in powdered glass. Accent colors were added
-by rolling the heated piece over fragments of crashed glass, creating
-the speckled effect. There are various types of onionskins: single
-color, speckled, and segmented. Sometimes mica was added to the glass,
-thus increasing its value. Onionskins were known to exist from the
-beginning of the cane-cut marble industry. An early example, dated
-between 1850 and 1860 was unearthed in the excavation of an old privy
-in New Orleans.'''
+        Onionskins - Although this cane-cut swirl usually has at its center a
+        clear glass core, it appears solidly colored because the clear core is
+        covered by a thin layer of opaque color and then covered again by a
+        thin layer of clear glass. Extremely popular and highly prized,
+        onionskins take their name from the layering of glass, like layers of
+        an onion. In contrast to end of day marbles, onion skins have two
+        pontils. The base color, usually white or yellow, was applied by
+        rolling clear glass marble in powdered glass. Accent colors were added
+        by rolling the heated piece over fragments of crashed glass, creating
+        the speckled effect. There are various types of onionskins: single
+        color, speckled, and segmented. Sometimes mica was added to the glass,
+        thus increasing its value. Onionskins were known to exist from the
+        beginning of the cane-cut marble industry. An early example, dated
+        between 1850 and 1860 was unearthed in the excavation of an old privy
+        in New Orleans.'''
         self.assertTrue(False, note=note)
 
     def test_long_line_in_note(self):
         note = '''
-OnionskinsAlthoughthiscanecutswirlusuallyhasatitscenteraclearglasscoreitappears
-solidly colored because the clear core is covered by a thin layer of
-opaque color and then covered again by a thin layer of clear
-glass. Extremely popular and highly prized, onionskins take their name
-from the layering of glass, like layers of an onion. In contrast to
-end of day marbles, onion skins have two pontils. The base color,
-usually white or yellow, was applied by rolling clear glass marble in
-powdered glass. Accent colors were added by rolling the heated piece
-over fragments of crashed glass, creating the speckled effect. There
-are various types of onionskins: single color, speckled, and
-segmented. Sometimes mica was added to the glass, thus increasing its
-value. Onionskins were known to exist from the beginning of the
-cane-cut marble industry. An early example, dated between 1850 and
-1860 was unearthed in the excavation of an old privy in New
-Orleans.'''
+        OnionskinsAlthoughthiscanecutswirlusuallyhasatitscenteraclearglasscoreitappears
+        solidly colored because the clear core is covered by a thin layer of
+        opaque color and then covered again by a thin layer of clear
+        glass. Extremely popular and highly prized, onionskins take their name
+        from the layering of glass, like layers of an onion. In contrast to
+        end of day marbles, onion skins have two pontils. The base color,
+        usually white or yellow, was applied by rolling clear glass marble in
+        powdered glass. Accent colors were added by rolling the heated piece
+        over fragments of crashed glass, creating the speckled effect. There
+        are various types of onionskins: single color, speckled, and
+        segmented. Sometimes mica was added to the glass, thus increasing its
+        value. Onionskins were known to exist from the beginning of the
+        cane-cut marble industry. An early example, dated between 1850 and
+        1860 was unearthed in the excavation of an old privy in New
+        Orleans.'''
         self.assertTrue(False, note=note)
 
     def test_multi_paragraphs_in_note(self):
         note = '''
-Onionskins - Although this cane-cut swirl usually has at its center a
-clear glass core, it appears solidly colored because the clear core is
-covered by a thin layer of opaque color and then covered again by a
-thin layer of clear glass. Extremely popular and highly prized,
-onionskins take their name from the layering of glass, like layers of
-an onion.
-
-In contrast to end of day marbles, onion skins have two pontils. The
-base color, usually white or yellow, was applied by rolling clear glass
-marble in powdered glass. Accent colors were added by rolling the
-heated piece over fragments of crashed glass, creating the speckled
-effect.
-
-There are various types of onionskins: single color, speckled, and
-segmented. Sometimes mica was added to the glass, thus increasing its
-value. Onionskins were known to exist from the beginning of the
-cane-cut marble industry. An early example, dated between 1850 and 1860
-was unearthed in the excavation of an old privy in New Orleans.'''
+        Onionskins - Although this cane-cut swirl usually has at its center a
+        clear glass core, it appears solidly colored because the clear core is
+        covered by a thin layer of opaque color and then covered again by a
+        thin layer of clear glass. Extremely popular and highly prized,
+        onionskins take their name from the layering of glass, like layers of
+        an onion.
+
+        In contrast to end of day marbles, onion skins have two pontils. The
+        base color, usually white or yellow, was applied by rolling clear glass
+        marble in powdered glass. Accent colors were added by rolling the
+        heated piece over fragments of crashed glass, creating the speckled
+        effect.
+
+        There are various types of onionskins: single color, speckled, and
+        segmented. Sometimes mica was added to the glass, thus increasing its
+        value. Onionskins were known to exist from the beginning of the
+        cane-cut marble industry. An early example, dated between 1850 and 1860
+        was unearthed in the excavation of an old privy in New Orleans.'''
         self.assertTrue(False, note=note)
 
     def test_list_in_note(self):
         note = '''
-There are various types of onionskins:
+        There are various types of onionskins:
 
-    1. single color,
+            1. single color,
 
-    2. speckled,
+            2. speckled,
 
-    3. and segmented.
+            3. and segmented.
 
-    42. Sometimes mica was added to the glass, thus increasing its
-value. Onionskins were known to exist from the beginning of the cane-
-cut marble industry. An early example, dated between 1850 and 1860 was
-unearthed in the excavation of an old privy in New Orleans.
+            42. Sometimes mica was added to the glass, thus increasing its
+        value. Onionskins were known to exist from the beginning of the cane-
+        cut marble industry. An early example, dated between 1850 and 1860 was
+        unearthed in the excavation of an old privy in New Orleans.
 
-There are various types of onionskins:
+        There are various types of onionskins:
 
-    a) single color,
+            a) single color,
 
-    b) speckled,
+            b) speckled,
 
-    c) and segmented.
+            c) and segmented.
 
-    d) Sometimes mica was added to the glass, thus increasing its
-value. Onionskins were known to exist from the beginning of the cane-
-cut marble industry. An early example, dated between 1850 and 1860 was
-unearthed in the excavation of an old privy in New Orleans.'''
+            d) Sometimes mica was added to the glass, thus increasing its
+        value. Onionskins were known to exist from the beginning of the cane-
+        cut marble industry. An early example, dated between 1850 and 1860 was
+        unearthed in the excavation of an old privy in New Orleans.'''
         self.assertTrue(False, note=note)
 
     def test_assert_raises_success(self):