File: test_log.py

package info (click to toggle)
f3d 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,504 kB
  • sloc: cpp: 99,106; python: 758; sh: 342; xml: 223; java: 101; javascript: 95; makefile: 25
file content (44 lines) | stat: -rw-r--r-- 924 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import subprocess
import sys


def test_default_level():
    assert (
        run_python(
            "from f3d import Log",
            "Log.set_use_coloring(False)",
            "Log.print(Log.DEBUG, 'debug')",
            "Log.print(Log.INFO, 'info')",
        )
        == "info\n"
    )


def test_debug():
    assert (
        run_python(
            "from f3d import Log",
            "Log.set_use_coloring(False)",
            "Log.set_verbose_level(Log.DEBUG)",
            "Log.print(Log.DEBUG, 'debug')",
        )
        == "debug\n"
    )


def test_coloring():
    assert (
        run_python(
            "from f3d import Log",
            "Log.set_use_coloring(True)",
            "Log.print(Log.INFO, 'info')",
        )
        == "info\x1b[0m\n"
    )


def run_python(*statements: str):
    return subprocess.check_output(
        [sys.executable, "-c", "; ".join(statements)],
        text=True,
    )