From ce8b457baca6a6bc92eceeecd17e1932c896ee98 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Mon, 12 Feb 2018 13:43:22 +0000 Subject: [PATCH] Only display exception type if no traceback Update test to match --- qutebrowser/config/configexc.py | 8 +++++--- tests/unit/config/test_configexc.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qutebrowser/config/configexc.py b/qutebrowser/config/configexc.py index 7be1ccf2a..c85aa2220 100644 --- a/qutebrowser/config/configexc.py +++ b/qutebrowser/config/configexc.py @@ -92,9 +92,11 @@ class ConfigErrorDesc: traceback = attr.ib(None) def __str__(self): - return '{} - {}: {} '.format(self.text, - self.exception.__class__.__name__, - self.exception) + if self.traceback: + return '{} - {}: {} '.format(self.text, + self.exception.__class__.__name__, + self.exception) + return '{}: {}'.format(self.text, self.exception) def with_text(self, text): """Get a new ConfigErrorDesc with the given text appended.""" diff --git a/tests/unit/config/test_configexc.py b/tests/unit/config/test_configexc.py index f415ed2fb..2f2ce435f 100644 --- a/tests/unit/config/test_configexc.py +++ b/tests/unit/config/test_configexc.py @@ -74,7 +74,7 @@ def test_config_file_errors_str(errors): assert str(errors).splitlines() == [ 'Errors occurred while reading config.py:', ' Error text 1: Exception 1', - ' Error text 2: Exception 2', + ' Error text 2 - Exception: Exception 2 ', ]