(self, statement, args=None)
| 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")) |
no test coverage detected