twosigma/marbles

Dedent note before reformatting

thejunglejane opened this issue · 1 comments

We want to allow users to write notes as triple-quoted multiline strings that are:

  1. indented in the source
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)
  1. lined up all the way to the left of the test output
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 on the note before we do the remaining reformatting.

I'd love to help out with this if it's still open!