amend to e786dbf132689133c29671871718a97f93b8912a: removes space between name and [pid] by normal non-verbose logging, padding without truncate now; test coverage for getVerbosityFormat;

closes #2734
pull/2814/head
sebres 2020-05-26 13:14:37 +02:00
parent b8e2b77265
commit 9b6da03c90
2 changed files with 10 additions and 2 deletions

View File

@ -302,7 +302,7 @@ def getVerbosityFormat(verbosity, fmt=' %(message)s', addtime=True, padding=True
if addtime:
fmt = ' %(asctime)-15s' + fmt
else: # default (not verbose):
fmt = "%(name)-23.23s [%(process)d]: %(levelname)-7s" + fmt
fmt = "%(name)-24s[%(process)d]: %(levelname)-7s" + fmt
if addtime:
fmt = "%(asctime)s " + fmt
# remove padding if not needed:

View File

@ -34,7 +34,7 @@ from StringIO import StringIO
from utils import LogCaptureTestCase, logSys as DefLogSys
from ..helpers import formatExceptionInfo, mbasename, TraceBack, FormatterWithTraceBack, getLogger, \
splitwords, uni_decode, uni_string
getVerbosityFormat, splitwords, uni_decode, uni_string
from ..server.mytime import MyTime
@ -404,6 +404,14 @@ class TestsUtilsTest(LogCaptureTestCase):
self._testAssertionErrorRE(r"\['A', 'B'\] != \['B', 'C'\]",
self.assertSortedEqual, ['A', 'B'], ['C', 'B'])
def testVerbosityFormat(self):
self.assertEqual(getVerbosityFormat(1),
'%(asctime)s %(name)-24s[%(process)d]: %(levelname)-7s %(message)s')
self.assertEqual(getVerbosityFormat(1, padding=False),
'%(asctime)s %(name)s[%(process)d]: %(levelname)s %(message)s')
self.assertEqual(getVerbosityFormat(1, addtime=False, padding=False),
'%(name)s[%(process)d]: %(levelname)s %(message)s')
def testFormatterWithTraceBack(self):
strout = StringIO()
Formatter = FormatterWithTraceBack