mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
merge
This commit is contained in:
commit
f804f3a507
1 changed files with 25 additions and 23 deletions
|
@ -3484,29 +3484,31 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
|
||||||
def test_rollover(self):
|
def test_rollover(self):
|
||||||
fh = logging.handlers.TimedRotatingFileHandler(self.fn, 'S',
|
fh = logging.handlers.TimedRotatingFileHandler(self.fn, 'S',
|
||||||
backupCount=1)
|
backupCount=1)
|
||||||
r = logging.makeLogRecord({'msg': 'testing'})
|
try:
|
||||||
fh.emit(r)
|
r = logging.makeLogRecord({'msg': 'testing'})
|
||||||
self.assertLogFile(self.fn)
|
fh.emit(r)
|
||||||
time.sleep(1.0)
|
self.assertLogFile(self.fn)
|
||||||
fh.emit(r)
|
time.sleep(1.0)
|
||||||
now = datetime.datetime.now()
|
fh.emit(r)
|
||||||
prevsec = now - datetime.timedelta(seconds=1)
|
now = datetime.datetime.now()
|
||||||
earlier = now - datetime.timedelta(seconds=2)
|
prevsec = now - datetime.timedelta(seconds=1)
|
||||||
fn1 = self.fn + prevsec.strftime(".%Y-%m-%d_%H-%M-%S")
|
earlier = now - datetime.timedelta(seconds=2)
|
||||||
fn2 = self.fn + earlier.strftime(".%Y-%m-%d_%H-%M-%S")
|
fn1 = self.fn + prevsec.strftime(".%Y-%m-%d_%H-%M-%S")
|
||||||
success = os.path.exists(fn1) or os.path.exists(fn2)
|
fn2 = self.fn + earlier.strftime(".%Y-%m-%d_%H-%M-%S")
|
||||||
if not success:
|
success = os.path.exists(fn1) or os.path.exists(fn2)
|
||||||
# print additional diagnostic information
|
if not success:
|
||||||
print('Neither %s nor %s exists' % (fn1, fn2), file=sys.stderr)
|
# print additional diagnostic information
|
||||||
dirname = os.path.dirname(fn1)
|
print('Neither %s nor %s exists' % (fn1, fn2), file=sys.stderr)
|
||||||
files = os.listdir(dirname)
|
dirname = os.path.dirname(fn1)
|
||||||
files = [f for f in files if f.startswith('test_logging-2-')]
|
files = os.listdir(dirname)
|
||||||
print('matching files: %s' % files, file=sys.stderr)
|
files = [f for f in files if f.startswith('test_logging-2-')]
|
||||||
self.assertTrue(success)
|
print('matching files: %s' % files, file=sys.stderr)
|
||||||
for fn in (fn1, fn2):
|
self.assertTrue(success)
|
||||||
if os.path.exists(fn):
|
for fn in (fn1, fn2):
|
||||||
self.rmfiles.append(fn)
|
if os.path.exists(fn):
|
||||||
|
self.rmfiles.append(fn)
|
||||||
|
finally:
|
||||||
|
fh.close()
|
||||||
|
|
||||||
def test_invalid(self):
|
def test_invalid(self):
|
||||||
assertRaises = self.assertRaises
|
assertRaises = self.assertRaises
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue