summaryrefslogtreecommitdiff
path: root/src/zope/security/tests/__init__.py
blob: cab4c90e58a87afb0f2cb7459bef55e4ce84e696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import io


class QuietWatchingChecker(object):
    # zope.testrunner does not support setUp/tearDownModule,
    # so we use a mixin class to make sure we don't flood stderr
    # with pointless printing when testing watching checkers

    def setUp(self):
        from zope.security import checker
        self.__old_file = checker.CheckerLoggingMixin._file
        checker.CheckerLoggingMixin._file = io.StringIO() if bytes is not str else io.BytesIO()

    def tearDown(self):
        from zope.security import checker
        checker.CheckerLoggingMixin._file = self.__old_file