def test_exc_info_on_loglevel(self):
        def raise_exception_on_purpose():
            0/1  # pylint: disable=pointless-statement

        log = saltlog.SaltLoggingClass(__name__)

        # Only stream2 should contain the traceback
        stream1 = StringIO()
        stream2 = StringIO()
        handler1 = StreamHandler(stream1)
        handler2 = StreamHandler(stream2)

        handler1.setLevel(logging.INFO)
        handler2.setLevel(logging.DEBUG)

        log.addHandler(handler1)
        log.addHandler(handler2)

        try:
            raise_exception_on_purpose()
        except ZeroDivisionError as exc:
            log.error('Exception raised on purpose caught: ZeroDivisionError',
                      exc_info_on_loglevel=logging.DEBUG)

        try:
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream1.getvalue()
            )
            self.assertNotIn('Traceback (most recent call last)', stream1.getvalue())
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream2.getvalue()
            )
            self.assertIn('Traceback (most recent call last)', stream2.getvalue())
        finally:
            log.removeHandler(handler1)
            log.removeHandler(handler2)

        # Both streams should contain the traceback
        stream1 = StringIO()
        stream2 = StringIO()
        handler1 = StreamHandler(stream1)
        handler2 = StreamHandler(stream2)

        handler1.setLevel(logging.INFO)
        handler2.setLevel(logging.DEBUG)

        log.addHandler(handler1)
        log.addHandler(handler2)

        try:
            raise_exception_on_purpose()
        except ZeroDivisionError as exc:
            log.error('Exception raised on purpose caught: ZeroDivisionError',
                      exc_info_on_loglevel=logging.INFO)

        try:
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream1.getvalue()
            )
            self.assertIn('Traceback (most recent call last)', stream1.getvalue())
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream2.getvalue()
            )
            self.assertIn('Traceback (most recent call last)', stream2.getvalue())
        finally:
            log.removeHandler(handler1)
            log.removeHandler(handler2)

        # No streams should contain the traceback
        stream1 = StringIO()
        stream2 = StringIO()
        handler1 = StreamHandler(stream1)
        handler2 = StreamHandler(stream2)

        handler1.setLevel(logging.ERROR)
        handler2.setLevel(logging.INFO)

        log.addHandler(handler1)
        log.addHandler(handler2)

        try:
            raise_exception_on_purpose()
        except ZeroDivisionError as exc:
            log.error('Exception raised on purpose caught: ZeroDivisionError',
                      exc_info_on_loglevel=logging.DEBUG)

        try:
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream1.getvalue()
            )
            self.assertNotIn('Traceback (most recent call last)', stream1.getvalue())
            self.assertIn(
                'Exception raised on purpose caught: ZeroDivisionError',
                stream2.getvalue()
            )
            self.assertNotIn('Traceback (most recent call last)', stream2.getvalue())
        finally:
            log.removeHandler(handler1)
            log.removeHandler(handler2)
dataset/ETHPy150Open saltstack/salt/tests/unit/log_test.py/TestLog.test_exc_info_on_loglevel/swapped operands of `/`