예제 #1
0
파일: test_log.py 프로젝트: 66laps/celery
 def with_wrap_logger(sio):
     p = LoggingProxy(logger)
     p.close()
     p.write("foo")
     self.assertNotIn("foo", sio.getvalue())
     p.closed = False
     p.write("foo")
     self.assertIn("foo", sio.getvalue())
     lines = ["baz", "xuzzy"]
     p.writelines(lines)
     for line in lines:
         self.assertIn(line, sio.getvalue())
     p.flush()
     p.close()
     self.assertFalse(p.isatty())
     self.assertIsNone(p.fileno())
예제 #2
0
 def with_wrap_logger(sio):
     p = LoggingProxy(logger)
     p.close()
     p.write("foo")
     self.assertNotIn("foo", sio.getvalue())
     p.closed = False
     p.write("foo")
     self.assertIn("foo", sio.getvalue())
     lines = ["baz", "xuzzy"]
     p.writelines(lines)
     for line in lines:
         self.assertIn(line, sio.getvalue())
     p.flush()
     p.close()
     self.assertFalse(p.isatty())
     self.assertIsNone(p.fileno())
예제 #3
0
    def test_logging_proxy(self):
        logger = self.setup_logger(loglevel=logging.ERROR, logfile=None, root=False)

        with wrap_logger(logger) as sio:
            p = LoggingProxy(logger, loglevel=logging.ERROR)
            p.close()
            p.write("foo")
            self.assertNotIn("foo", sio.getvalue())
            p.closed = False
            p.write("foo")
            self.assertIn("foo", sio.getvalue())
            lines = ["baz", "xuzzy"]
            p.writelines(lines)
            for line in lines:
                self.assertIn(line, sio.getvalue())
            p.flush()
            p.close()
            self.assertFalse(p.isatty())
            self.assertIsNone(p.fileno())
예제 #4
0
    def test_logging_proxy(self):
        logger = self.setup_logger(loglevel=logging.ERROR, logfile=None,
                                   root=False)

        with wrap_logger(logger) as sio:
            p = LoggingProxy(logger, loglevel=logging.ERROR)
            p.close()
            p.write("foo")
            self.assertNotIn("foo", sio.getvalue())
            p.closed = False
            p.write("foo")
            self.assertIn("foo", sio.getvalue())
            lines = ["baz", "xuzzy"]
            p.writelines(lines)
            for line in lines:
                self.assertIn(line, sio.getvalue())
            p.flush()
            p.close()
            self.assertFalse(p.isatty())
            self.assertIsNone(p.fileno())