tox-dev / tox
1 15
import socket
2 15
import sys
3 15
from typing import Any, Dict
4

5 15
import pytest
6

7 15
from tox import __version__
8 15
from tox.journal.main import Journal
9

10

11 15
@pytest.fixture()
12 15
def base_info() -> Dict[str, Any]:
13 15
    return {
14
        "reportversion": "1",
15
        "toxversion": __version__,
16
        "platform": sys.platform,
17
        "host": socket.getfqdn(),
18
    }
19

20

21 15
def test_journal_enabled_default(base_info: Dict[str, Any]) -> None:
22 15
    journal = Journal(enabled=True)
23 15
    assert bool(journal) is True
24 15
    assert journal.content == base_info
25

26

27 15
def test_journal_disabled_default() -> None:
28 15
    journal = Journal(enabled=False)
29 15
    assert bool(journal) is False
30 15
    assert journal.content == {}
31

32

33 15
def test_env_journal_enabled(base_info: Dict[str, Any]) -> None:
34 15
    journal = Journal(enabled=True)
35 15
    env = journal.get_env_journal("a")
36 15
    assert journal.get_env_journal("a") is env
37 15
    env["demo"] = 1
38

39 15
    assert bool(env) is True
40 15
    base_info["testenvs"] = {"a": {"demo": 1}}
41 15
    assert journal.content == base_info
42

43

44 15
def test_env_journal_disabled() -> None:
45 15
    journal = Journal(enabled=False)
46 15
    env = journal.get_env_journal("a")
47 15
    assert bool(env) is False
48

49 15
    env["demo"] = 2
50 15
    assert journal.content == {"testenvs": {"a": {"demo": 2}}}

Read our documentation on viewing source code .

Loading