diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-12-28 20:53:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-12-28 20:53:21 +0200 |
commit | c4d4310d801ccf20ea73717eb05ea27d4c6fbc62 (patch) | |
tree | e9935ae2c5b6690359dffc6b0989503ed6354516 /obnamlib | |
parent | 4b82cdec0cceb61abb6d1c933212e35b38f26e29 (diff) | |
download | obnam-c4d4310d801ccf20ea73717eb05ea27d4c6fbc62.tar.gz |
Remove trailing whitespace
Diffstat (limited to 'obnamlib')
-rw-r--r-- | obnamlib/structurederror.py | 11 | ||||
-rw-r--r-- | obnamlib/structurederror_tests.py | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/obnamlib/structurederror.py b/obnamlib/structurederror.py index 81c4d5a4..18c13e5a 100644 --- a/obnamlib/structurederror.py +++ b/obnamlib/structurederror.py @@ -123,10 +123,17 @@ class StructuredError(Exception): formatted_msg = '{0} (PROGRAMMING ERROR: {1} {2})'.format( dedented, repr(e), repr(self.kwargs)) - return '{0}: {1}'.format(self.id, formatted_msg) + formatted = '{0}: {1}'.format(self.id, formatted_msg) + return formatted.rstrip() def formatted(self): - '''Return the full formatted message.''' + '''Return the full formatted message. + + Note that the returned string will NOT end in whitespace. If + the format string ends in, say, a newline, it is stripped + away. + + ''' return self._format_msg(self.msg) def __str__(self): diff --git a/obnamlib/structurederror_tests.py b/obnamlib/structurederror_tests.py index ef49daca..b11909c0 100644 --- a/obnamlib/structurederror_tests.py +++ b/obnamlib/structurederror_tests.py @@ -68,6 +68,11 @@ class StructuredErrorTests(unittest.TestCase): first = FirstError() self.assertIn('\n', first.formatted()) + def test_formatted_message_does_not_end_in_whitespace(self): + first = FirstError() + formatted = first.formatted() + self.assertFalse(formatted[-1].isspace()) + def test_handles_empty_message_string(self): empty = EmptyError() self.assertTrue(str(empty).rstrip().endswith(':')) |