Skip to content

Commit

Permalink
Added test for WMCore.WMLogging.MyTimedRotatingFileHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ylee committed Apr 9, 2024
1 parent 67865e1 commit 3358120
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/python/WMCore_t/WMLogging_t.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python
# encoding: utf-8
from builtins import range
from datetime import date
import logging
import unittest
import os
from WMCore.WMLogging import CouchHandler

from WMCore.WMLogging import CouchHandler, MyTimedRotatingFileHandler
from WMCore.Database.CMSCouch import CouchServer

class WMLoggingTest(unittest.TestCase):
Expand All @@ -25,6 +27,19 @@ def tearDown(self):
# This used to test self._exc_info to only run on success. Broke in 2.7. Removed.
self.server.deleteDatabase(self.dbname)

def testRotatingLogHandler(self):
"""
Test to make sure a date is in or will be added to the logName
"""
todayStr = date.today().strftime("%Y%m%d")
logName = "mylog.log"
handler = MyTimedRotatingFileHandler(logName, 'midnight', backupCount = 10)
self.assertIn(todayStr, handler.baseFilename)

logName = f"mylog-{todayStr}.log"
handler = MyTimedRotatingFileHandler(logName, 'midnight', backupCount = 10)
self.assertIn(todayStr, handler.baseFilename)

def testLog(self):
"""
Write ten log messages to the database at three different levels
Expand Down

0 comments on commit 3358120

Please sign in to comment.