@@ -1169,14 +1169,15 @@ def testCopyConfig(self):
11691169 self .assertEqual (config ['STATIC_FILES' ], None )
11701170
11711171 # load config
1172+ STATIC_FILES = os .path .join (self .dirname , "html2" )
11721173 config .load (self .dirname )
1173- self .assertEqual (config ['STATIC_FILES' ], ['_test_instance/html2' ])
1174+ self .assertEqual (config ['STATIC_FILES' ], [ STATIC_FILES ])
11741175
11751176 # copy config
11761177 config_copy = config .copy ()
11771178
11781179 # this should work
1179- self .assertEqual (config_copy ['STATIC_FILES' ], ['_test_instance/html2' ])
1180+ self .assertEqual (config_copy ['STATIC_FILES' ], [STATIC_FILES ])
11801181
11811182 @skip_py2
11821183 def testConfigValueInterpolateError (self ):
@@ -1272,13 +1273,14 @@ def testLoggerFormat(self):
12721273 configuration .ParsingOptionError ) as cm :
12731274 config .load (self .dirname )
12741275
1275- self .assertEqual (cm .exception .args [0 ],
1276- "Error in _test_instance/config.ini with section "
1276+ ini_path = os .path .join (self .dirname , "config.ini" )
1277+ self .assertEqual (cm .exception .args [0 ],(
1278+ f"Error in { ini_path } with section "
12771279 "[logging] at option format: Bad value substitution: "
12781280 "option 'format' in section 'logging' contains an "
12791281 "interpolation key 'asctime' which is not a valid "
12801282 "option name. Raw value: '%(asctime)s %%(trace_id)s "
1281- "%%(levelname) %%(message)s'" )
1283+ "%%(levelname) %%(message)s'" ))
12821284
12831285 def testDictLoggerConfigViaJson (self ):
12841286
@@ -1538,26 +1540,41 @@ def testDictLoggerConfigViaJson(self):
15381540 "%s'\n " % (log_config_filename , access_filename ))
15391541 self .assertEqual (output , target )
15401542
1541- def test_missing_logging_config_file (self ):
1542- saved_config = self .db .config ['LOGGING_CONFIG' ]
1543-
1544- self .db .config ['LOGGING_CONFIG' ] = 'logging.json'
1545-
1546- with self .assertRaises (configuration .OptionValueError ) as cm :
1547- self .db .config .init_logging ()
1543+ # mess up '}' so json file block isn't properly closed.
1544+ test_config = config1 .replace (
1545+ ' }' ,
1546+ ' ' )
15481547
1549- self .assertEqual (cm .exception .args [1 ], "_test_instance/logging.json" )
1550- self .assertEqual (cm .exception .args [2 ],
1551- "Unable to find logging config file." )
1548+ with open (log_config_filename , "w" ) as log_config_file :
1549+ log_config_file .write (test_config )
15521550
1553- self .db .config ['LOGGING_CONFIG' ] = 'logging.ini'
1551+ # file is made relative to tracker dir.
1552+ self .db .config ["LOGGING_CONFIG" ] = '_test_log_config.json'
1553+ with self .assertRaises (configuration .LoggingConfigError ) as cm :
1554+ config = self .db .config .init_logging ()
15541555
1555- with self .assertRaises (configuration .OptionValueError ) as cm :
1556- self .db .config .init_logging ()
1556+ output = cm .exception .args [0 ].replace (r'\\' ,'\\ ' )
1557+ target = ("Error parsing json logging dict "
1558+ "(%s) near \n \n "
1559+ " Error found at end of file. Maybe missing a "
1560+ "block closing '}'.\n \n "
1561+ "Expecting ',' delimiter: line 86 column 1." %
1562+ (log_config_filename ,))
1563+ self .assertEqual (output , target )
15571564
1558- self .assertEqual (cm .exception .args [1 ], "_test_instance/logging.ini" )
1559- self .assertEqual (cm .exception .args [2 ],
1560- "Unable to find logging config file." )
1565+ def test_missing_logging_config_file (self ):
1566+ saved_config = self .db .config ['LOGGING_CONFIG' ]
1567+
1568+ for logging_file in ["logging.json" , "logging.ini" , "logging.foobar" ]:
1569+ self .db .config ['LOGGING_CONFIG' ] = logging_file
1570+
1571+ with self .assertRaises (configuration .OptionValueError ) as cm :
1572+ self .db .config .init_logging ()
1573+
1574+ logging_configfile = os .path .join (self .dirname , logging_file )
1575+ self .assertEqual (cm .exception .args [1 ], logging_configfile )
1576+ self .assertEqual (cm .exception .args [2 ],
1577+ "Unable to find logging config file." )
15611578
15621579 self .db .config ['LOGGING_CONFIG' ] = saved_config
15631580
@@ -1566,11 +1583,12 @@ def test_unknown_logging_config_file_type(self):
15661583
15671584 self .db .config ['LOGGING_CONFIG' ] = 'schema.py'
15681585
1569-
1586+
15701587 with self .assertRaises (configuration .OptionValueError ) as cm :
15711588 self .db .config .init_logging ()
15721589
1573- self .assertEqual (cm .exception .args [1 ], "_test_instance/schema.py" )
1590+ logging_configfile = os .path .join (self .dirname , "schema.py" )
1591+ self .assertEqual (cm .exception .args [1 ], logging_configfile )
15741592 self .assertEqual (cm .exception .args [2 ],
15751593 "Unable to load logging config file. "
15761594 "File extension must be '.ini' or '.json'.\n " )
0 commit comments