File: tmp_06_reporting_classes.py

package info (click to toggle)
pyuvm 4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 992 kB
  • sloc: python: 8,662; makefile: 238; vhdl: 206; sh: 7
file content (29 lines) | stat: -rw-r--r-- 713 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
26
27
28
29
import pytest

from pyuvm import *


def test_object_creation():
    """
    Test that we actually get a logger in our object.
    """
    ro = uvm_report_object("ro")
    assert hasattr(ro, "logger")
    assert not ro.logger.propagate


@pytest.mark.parametrize(
    "level,msg",
    [
        (logging.DEBUG, "debug"),
        (logging.INFO, "info"),
        (logging.ERROR, "error"),
        (logging.CRITICAL, "critical"),
    ],
)
def test_logging(level, msg, caplog):
    ro = uvm_report_object("ro")
    ro.logger.propagate = True  # workaround for 'caplog'
    caplog.set_level(logging.DEBUG, ro.logger.name)
    ro.logger.log(level, msg)
    assert caplog.record_tuples == [(ro.logger.name, level, msg)]