# -*- coding: utf-8 -*-
# Copyright 2014 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from twisted.trial import unittest

import logging


# logging doesn't have a "don't log anything at all EVARRRR setting,
# but since the highest value is 50, 1000000 should do ;)
NEVER = 1000000

logging.getLogger().addHandler(logging.StreamHandler())
logging.getLogger().setLevel(NEVER)


class TestCase(unittest.TestCase):
    pass

@@ -930,9 +930,649 @@
     
-pass
+def __init__(self, *args, **kwargs):%0A        super(TestCase, self).__init__(*args, **kwargs)%0A%0A        level = getattr(self, %22loglevel%22, NEVER)%0A%0A        orig_setUp = self.setUp%0A%0A        def setUp():%0A            old_level = logging.getLogger().level%0A%0A            if old_level != level:%0A                orig_tearDown = self.tearDown%0A%0A                def tearDown():%0A                    ret = orig_tearDown()%0A                    logging.getLogger().setLevel(old_level)%0A                    return ret%0A                self.tearDown = tearDown%0A%0A            logging.getLogger().setLevel(level)%0A            return orig_setUp()%0A        self.setUp = setUp
 %0A

Allow a TestCase to set a 'loglevel' attribute, which overrides the logging level while that testcase runs