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

Method logs_present

python/python3/tornado/test/log_test.py:199–215  ·  view source on GitHub ↗
(self, statement, args=None)

Source from the content-addressed store, hash-verified

197 """Test the ability to enable and disable Tornado's logging hooks."""
198
199 def logs_present(self, statement, args=None):
200 # Each test may manipulate and/or parse the options and then logs
201 # a line at the 'info' level. This level is ignored in the
202 # logging module by default, but Tornado turns it on by default
203 # so it is the easiest way to tell whether tornado's logging hooks
204 # ran.
205 IMPORT = "from tornado.options import options, parse_command_line"
206 LOG_INFO = 'import logging; logging.info("hello")'
207 program = ";".join([IMPORT, statement, LOG_INFO])
208 proc = subprocess.Popen(
209 [sys.executable, "-c", program] + (args or []),
210 stdout=subprocess.PIPE,
211 stderr=subprocess.STDOUT,
212 )
213 stdout, stderr = proc.communicate()
214 self.assertEqual(proc.returncode, 0, "process failed: %r" % stdout)
215 return b"hello" in stdout
216
217 def test_default(self):
218 self.assertFalse(self.logs_present("pass"))

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected