File: test_logging.py

package info (click to toggle)
drgn 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,852 kB
  • sloc: python: 74,992; ansic: 54,589; awk: 423; makefile: 351; sh: 99
file content (25 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (c) Meta Platforms, Inc. and affiliates.
# SPDX-License-Identifier: LGPL-2.1-or-later

import logging

from drgn import Program
from tests import TestCase


# Test that our monkey patch to sync the log level between the logging module
# and libdrgn works.
class TestLogging(TestCase):
    def test_set_level_before(self):
        logger = logging.getLogger("drgn")
        with self.assertLogs(logger, "DEBUG") as cm:
            prog = Program()
            prog._log(0, "foo")
        self.assertIn("DEBUG:drgn:foo", cm.output)

    def test_set_level_after(self):
        prog = Program()
        logger = logging.getLogger("drgn")
        with self.assertLogs(logger, "DEBUG") as cm:
            prog._log(0, "bar")
        self.assertIn("DEBUG:drgn:bar", cm.output)