@@ -1700,7 +1700,7 @@ def testIniFileLoggerConfig(self):
17001700 self .assertEqual (
17011701 cm .exception .args [0 ].replace (r'\\' ,'\\ ' ),
17021702 ('Error loading logging config from %s.\n \n '
1703- " Unknown level: 'DEBUF'\n \n "
1703+ " ValueError: Unknown level: 'DEBUF'\n \n "
17041704 'Inappropriate argument value (of correct type).\n ' %
17051705 log_config_filename )
17061706 )
@@ -1718,16 +1718,31 @@ def testIniFileLoggerConfig(self):
17181718 # verify that logging was reset
17191719 # default log config doesn't define handlers for roundup.http
17201720 self .assertEqual (len (logging .getLogger ('roundup.http' ).handlers ), 0 )
1721-
1722- self .assertEqual (
1723- cm .exception .args [0 ].replace (r'\\' ,'\\ ' ),
1724- ("Error loading logging config from %(filename)s.\n \n "
1725- " %(filename)s is invalid: Source contains parsing errors: "
1726- "'%(filename)s'\n \t [line 9]: '=foo\\ n'\n \n "
1727- "Source contains parsing errors: '%(filename)s'\n "
1728- "\t [line 9]: '=foo\\ n' Unspecified run-time error.\n " %
1729- {"filename" : log_config_filename })
1730- )
1721+
1722+ output = cm .exception .args [0 ].replace (r'\\' ,'\\ ' )
1723+
1724+ if sys .version_info >= (3 , 12 , 0 ):
1725+ expected = (
1726+ "Error loading logging config from %(filename)s.\n \n "
1727+ " RuntimeError: %(filename)s is invalid: Source contains parsing errors: "
1728+ "'%(filename)s'\n \t [line 9]: '=foo\\ n'\n \n "
1729+ "Source contains parsing errors: '%(filename)s'\n "
1730+ "\t [line 9]: '=foo\\ n' Unspecified run-time error.\n " %
1731+ {"filename" : log_config_filename })
1732+
1733+ else : # 3.7 <= x < 3.12.0
1734+
1735+ expected = (
1736+ "Error loading logging config from %(filename)s.\n \n "
1737+
1738+ " ParsingError: Source contains parsing errors: "
1739+ "'%(filename)s'\n "
1740+ "\t [line 9]: '=foo\\ n'\n \n "
1741+
1742+ "Raised when a configuration file does not follow legal "
1743+ "syntax.\n " % {"filename" : log_config_filename })
1744+
1745+ self .assertEqual (output , expected )
17311746 self .reset_logging ()
17321747
17331748 # handler = basic to handler = basi
@@ -1745,7 +1760,7 @@ def testIniFileLoggerConfig(self):
17451760 self .assertEqual (
17461761 cm .exception .args [0 ].replace (r'\\' ,'\\ ' ),
17471762 ("Error loading logging config from %(filename)s.\n \n "
1748- " basi\n \n "
1763+ " KeyError: ' basi' \n \n "
17491764 "Mapping key not found. No section found with this name.\n " %
17501765 {"filename" : log_config_filename })
17511766 )
@@ -1767,7 +1782,7 @@ def testIniFileLoggerConfig(self):
17671782 self .assertEqual (
17681783 cm .exception .args [0 ].replace (r'\\' ,'\\ ' ),
17691784 ("Error loading logging config from %(filename)s.\n \n "
1770- " No module named 'SHAndler'\n \n "
1785+ " ModuleNotFoundError: No module named 'SHAndler'\n \n "
17711786 "name 'SHAndler' is not defined Module not found.\n " %
17721787 {"filename" : log_config_filename })
17731788 )
0 commit comments