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


class QuietWatchingChecker:
    # 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