aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/test/frozen/support.py
blob: e08b89e33b3e32acdc80f202864f9eee5d1df56c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sys


class Null:

    """Just absorb what is given."""

    def __getattr__(self):
        return lambda *args, **kwargs: None


class SilenceStdout:

    """Silence sys.stdout."""

    def setUp(self):
        """Substitute sys.stdout with something that does not print to the
        screen thanks to what bytecode is frozen."""
        sys.stdout = Null()
        super().setUp()

    def tearDown(self):
        sys.stdout = sys.__stdout__
        super().tearDown()