summaryrefslogtreecommitdiffstats
path: root/examples/tests/conftest.py
blob: a566ff028fa5492efde39bd6ceeadb094c4297f4 (plain)
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
import logging
import pytest

from .ngtcp2test import Env


@pytest.mark.usefixtures("env")
def pytest_report_header(config):
    env = Env()
    return [
        f"ngtcp2-examples: [{env.version}, crypto_libs={env.crypto_libs}]",
        f"example clients: {env.clients}",
        f"example servers: {env.servers}",
    ]


@pytest.fixture(scope="package")
def env(pytestconfig) -> Env:
    console = logging.StreamHandler()
    console.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
    logging.getLogger('').addHandler(console)
    env = Env(pytestconfig=pytestconfig)
    level = logging.DEBUG if env.verbose > 0 else logging.INFO
    console.setLevel(level)
    logging.getLogger('').setLevel(level=level)
    env.setup()

    return env