Example #1
0
 def test_setup_logging_no_color(self):
     worker = self.Worker(
         app=self.app, redirect_stdouts=False, no_color=True,
     )
     prev, self.app.log.setup = self.app.log.setup, Mock()
     worker.setup_logging()
     self.assertFalse(self.app.log.setup.call_args[1]['colorize'])
Example #2
0
 def test_setup_logging_no_color(self):
     worker = self.Worker(
         app=self.app, redirect_stdouts=False, no_color=True,
     )
     prev, self.app.log.setup = self.app.log.setup, Mock()
     worker.setup_logging()
     self.assertFalse(self.app.log.setup.call_args[1]['colorize'])
Example #3
0
 def test_setup_logging_no_color(self):
     worker = self.Worker(app=self.app, redirect_stdouts=False, no_color=True)
     prev, self.app.log.setup = self.app.log.setup, Mock()
     try:
         worker.setup_logging()
         self.assertFalse(self.app.log.setup.call_args[1]["colorize"])
     finally:
         self.app.log.setup = prev
Example #4
0
    def test_redirect_stdouts_already_handled(self):
        logging_setup = [False]

        @signals.setup_logging.connect
        def on_logging_setup(**kwargs):
            logging_setup[0] = True

        try:
            worker = self.Worker(app=self.app, redirect_stdouts=False)
            worker.app.log.already_setup = False
            worker.setup_logging()
            self.assertTrue(logging_setup[0])
            with self.assertRaises(AttributeError):
                sys.stdout.logger
        finally:
            signals.setup_logging.disconnect(on_logging_setup)
    def test_redirect_stdouts_already_handled(self):
        logging_setup = [False]

        @signals.setup_logging.connect
        def on_logging_setup(**kwargs):
            logging_setup[0] = True

        try:
            worker = self.Worker(app=self.app, redirect_stdouts=False)
            worker.app.log.already_setup = False
            worker.setup_logging()
            assert logging_setup[0]
            with pytest.raises(AttributeError):
                sys.stdout.logger
        finally:
            signals.setup_logging.disconnect(on_logging_setup)
Example #6
0
    def test_redirect_stdouts_already_handled(self):
        logging_setup = [False]

        @signals.setup_logging.connect
        def on_logging_setup(**kwargs):
            logging_setup[0] = True

        try:
            worker = self.Worker(redirect_stdouts=False)
            worker.app.log.__class__._setup = False
            worker.setup_logging()
            self.assertTrue(logging_setup[0])
            with self.assertRaises(AttributeError):
                sys.stdout.logger
        finally:
            signals.setup_logging.disconnect(on_logging_setup)