MCPcopy Create free account
hub / github.com/EasyIME/PIME / test_log_file

Method test_log_file

python/python3/tornado/test/log_test.py:140–158  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

138 self.logger.propagate = False
139
140 def test_log_file(self):
141 tmpdir = tempfile.mkdtemp()
142 try:
143 self.options.log_file_prefix = tmpdir + "/test_log"
144 enable_pretty_logging(options=self.options, logger=self.logger)
145 self.assertEqual(1, len(self.logger.handlers))
146 self.logger.error("hello")
147 self.logger.handlers[0].flush()
148 filenames = glob.glob(tmpdir + "/test_log*")
149 self.assertEqual(1, len(filenames))
150 with open(filenames[0]) as f:
151 self.assertRegex(f.read(), r"^\[E [^]]*\] hello$")
152 finally:
153 for handler in self.logger.handlers:
154 handler.flush()
155 handler.close()
156 for filename in glob.glob(tmpdir + "/test_log*"):
157 os.unlink(filename)
158 os.rmdir(tmpdir)
159
160 def test_log_file_with_timed_rotating(self):
161 tmpdir = tempfile.mkdtemp()

Callers

nothing calls this directly

Calls 4

enable_pretty_loggingFunction · 0.90
errorMethod · 0.80
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected