|
From: Mercurial C. <th...@in...> - 2026-05-12 21:11:59
|
# HG changeset patch
# User John Rouillard <ro...@ie...>
# Date 1778520662 14400
# Mon May 11 13:31:02 2026 -0400
# Node ID 1352ae565dee514bfbf2631e56ac8c047ffd9700
# Parent 75bd16f814a465b45a2e031e456666f652891a41
test: remove test log files.
The testIniFileLogger creates some log files. Make the log file names
unique so we don't delete a real log file.
Note I use an f-string for some substituition because the logging
config is meant to be processed using % style substitutions. So I
can't use % style tokens.
Also fix some whitespace stuff.
diff -r 75bd16f814a4 -r 1352ae565dee test/test_config.py
--- a/test/test_config.py Mon May 11 12:16:41 2026 -0400
+++ b/test/test_config.py Mon May 11 13:31:02 2026 -0400
@@ -499,6 +499,8 @@
backend = 'anydbm'
+ nonce = "JJxyzzy" # use a real nonce at some point
+
def setUp(self):
self.dirname = '_test_instance'
# set up and open a tracker
@@ -1578,7 +1580,7 @@
def testIniFileLoggerConfig(self):
# good base test case
- config1 = dedent("""
+ config1 = dedent(f"""
[loggers]
keys=root,roundup,roundup.http,roundup.hyperdb,actions,schema,extension,detector
@@ -1646,12 +1648,12 @@
[handler_rotate]
class=logging.handlers.RotatingFileHandler
- args=('roundup.log','a', 512000, 2)
+ args=('roundup_test-{self.nonce}.log','a', 512000, 2)
formatter=basic
[handler_rotate_weblog]
class=logging.handlers.RotatingFileHandler
- args=('httpd.log','a', 512000, 2)
+ args=('httpd_test-{self.nonce}.log','a', 512000, 2)
formatter=plain
[formatters]
@@ -1741,7 +1743,7 @@
self.assertEqual(output, expected)
self.reset_logging()
-
+
# handler = basic to handler = basi
test_config = config1.replace("handlers=basic\n", "handlers=basi\n", 1)
with open(log_config_filename, "w") as log_config_file:
@@ -1793,7 +1795,7 @@
with self.assertRaises(configparser.DuplicateOptionError) as cm:
config = self.db.config.init_logging()
-
+
# verify that logging was reset
# default log config doesn't define handlers for roundup.http
self.assertEqual(len(logging.getLogger('roundup.http').handlers), 0)
@@ -1805,7 +1807,12 @@
{"filename": log_config_filename})
)
self.reset_logging()
-
+
+ for logfile in ['roundup_test-%(nonce)s.log' % {"nonce": self.nonce},
+ 'httpd_test-%(nonce)s.log' % {"nonce": self.nonce} ]:
+ if os.path.exists(logfile):
+ os.remove(logfile)
+
def test_missing_logging_config_file(self):
saved_config = self.db.config['LOGGING_CONFIG']
|