Mercurial > p > roundup > code
changeset 8456:9f7e863fd1cd
merge multiple fix: python < 3.12 returns ParsingError not RuntimeError; print exception
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 22 Sep 2025 14:08:36 -0400 |
| parents | 588ae856cd57 |
| children | f7fadbac5856 |
| files | roundup/configuration.py test/test_config.py |
| diffstat | 2 files changed, 28 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/configuration.py Mon Sep 22 13:09:49 2025 -0400 +++ b/roundup/configuration.py Mon Sep 22 14:08:36 2025 -0400 @@ -2660,7 +2660,7 @@ "Error loading logging config from %(file)s.\n\n" " %(msg)s\n\n%(context)s\n" % { "file": _file, - "msg": e.args[0], + "msg": type(e).__name__ + ": " + str(e), "context": " ".join(context), } )
--- a/test/test_config.py Mon Sep 22 13:09:49 2025 -0400 +++ b/test/test_config.py Mon Sep 22 14:08:36 2025 -0400 @@ -1700,7 +1700,7 @@ self.assertEqual( cm.exception.args[0].replace(r'\\','\\'), ('Error loading logging config from %s.\n\n' - " Unknown level: 'DEBUF'\n\n" + " ValueError: Unknown level: 'DEBUF'\n\n" 'Inappropriate argument value (of correct type).\n' % log_config_filename) ) @@ -1718,16 +1718,31 @@ # verify that logging was reset # default log config doesn't define handlers for roundup.http self.assertEqual(len(logging.getLogger('roundup.http').handlers), 0) + + output = cm.exception.args[0].replace(r'\\','\\') + + if sys.version_info >= (3, 12, 0): + expected = ( + "Error loading logging config from %(filename)s.\n\n" + " %(filename)s is invalid: Source contains parsing errors: " + "'%(filename)s'\n\t[line 9]: '=foo\\n'\n\n" + "Source contains parsing errors: '%(filename)s'\n" + "\t[line 9]: '=foo\\n' Unspecified run-time error.\n" % + {"filename": log_config_filename}) + + else: # 3.7 <= x < 3.12.0 + + expected = ( + "Error loading logging config from %(filename)s.\n\n" + " ParsingError: Source contains parsing errors: " + "'%(filename)s'\n" + "\t[line 9]: '=foo\\n'\n\n" + "Raised when a configuration file does not follow legal " + "syntax.\n" % {"filename": log_config_filename}) + + print(output) - self.assertEqual( - cm.exception.args[0].replace(r'\\','\\'), - ("Error loading logging config from %(filename)s.\n\n" - " %(filename)s is invalid: Source contains parsing errors: " - "'%(filename)s'\n\t[line 9]: '=foo\\n'\n\n" - "Source contains parsing errors: '%(filename)s'\n" - "\t[line 9]: '=foo\\n' Unspecified run-time error.\n" % - {"filename": log_config_filename}) - ) + self.assertEqual(output, expected) self.reset_logging() # handler = basic to handler = basi @@ -1745,7 +1760,7 @@ self.assertEqual( cm.exception.args[0].replace(r'\\','\\'), ("Error loading logging config from %(filename)s.\n\n" - " basi\n\n" + " KeyError: 'basi'\n\n" "Mapping key not found. No section found with this name.\n" % {"filename": log_config_filename}) ) @@ -1767,7 +1782,7 @@ self.assertEqual( cm.exception.args[0].replace(r'\\','\\'), ("Error loading logging config from %(filename)s.\n\n" - " No module named 'SHAndler'\n\n" + " ModuleNotFoundError: No module named 'SHAndler'\n\n" "name 'SHAndler' is not defined Module not found.\n" % {"filename": log_config_filename}) )
