File: test_config.py

package info (click to toggle)
displaycal-py3 3.9.17-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 29,124 kB
  • sloc: python: 115,810; javascript: 11,545; xml: 598; sh: 257; makefile: 173
file content (100 lines) | stat: -rw-r--r-- 4,316 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-

import os
import sys


def test_default_values_1():
    """Test default values of module level variables."""
    from DisplayCAL import config

    config.initcfg()

    assert config.configparser.DEFAULTSECT == "Default"
    assert config.exe == sys.executable  # venv/bin/python
    assert config.exedir == os.path.dirname(sys.executable)  # venv/bin
    assert config.exename == os.path.basename(sys.executable)  # python
    assert config.isexe is False
    # $HOME/.local/bin/pycharm-{PYCHARMVERSION}/plugins/python/helpers/pycharm/_jb_pytest_runner.py
    assert config.pyfile != ""
    # $HOME/.local/bin/pycharm-{PYCHARMVERSION}/plugins/python/helpers/pycharm/_jb_pytest_runner.py
    assert config.pypath != ""
    assert config.isapp is False  #
    assert config.pyname != ""  # _jb_pytest_runner
    # assert config.pyext != ""  # .py  This is not valid when pytest runß directly
    # $HOME/Documents/development/displaycal/DisplayCAL
    assert config.pydir != ""

    if sys.platform == "linux":
        assert config.xdg_config_dir_default == "/etc/xdg"
        assert config.xdg_config_home == os.path.expanduser("~/.config")
        assert config.xdg_data_home == os.path.expanduser("~/.local/share")
        assert config.xdg_data_home_default == os.path.expanduser("~/.local/share")

    # skip the rest of the test for now
    return

    assert config.xdg_data_dirs == [
        "/usr/share/pop",
        os.path.expanduser("~/.local/share/flatpak/exports/share"),
        "/var/lib/flatpak/exports/share",
        "/usr/local/share",
        "/usr/share",
        "/var/lib",
    ]

    from DisplayCAL.__version__ import VERSION_STRING

    expected_data_dirs = [
        os.path.expanduser("~/.local/share/DisplayCAL"),
        os.path.expanduser("~/.local/share/doc/DisplayCAL"),
        os.path.expanduser(f"~/.local/share/doc/DisplayCAL-{VERSION_STRING}"),
        os.path.expanduser("~/.local/share/doc/displaycal"),
        os.path.expanduser("~/.local/share/doc/packages/DisplayCAL"),
        os.path.expanduser("~/.local/share/flatpak/exports/share/DisplayCAL"),
        os.path.expanduser("~/.local/share/flatpak/exports/share/doc/DisplayCAL"),
        os.path.expanduser(
            f"~/.local/share/flatpak/exports/share/doc/DisplayCAL-{VERSION_STRING}"
        ),
        os.path.expanduser("~/.local/share/flatpak/exports/share/doc/displaycal"),
        os.path.expanduser(
            "~/.local/share/flatpak/exports/share/doc/packages/DisplayCAL"
        ),
        os.path.expanduser("~/.local/share/flatpak/exports/share/icons/hicolor"),
        os.path.expanduser("~/.local/share/icons/hicolor"),
        config.pydir,
        os.path.expanduser(
            "~/PycharmProjects/DisplayCAL/venv/lib/python3.9/site-packages/DisplayCAL-3.8.9.3-py3.9-linux-x86_64.egg/DisplayCAL"
        ),
        "/usr/local/share/DisplayCAL",
        "/usr/local/share/doc/DisplayCAL",
        f"/usr/local/share/doc/DisplayCAL-{VERSION_STRING}",
        "/usr/local/share/doc/displaycal",
        "/usr/local/share/doc/packages/DisplayCAL",
        "/usr/local/share/icons/hicolor",
        "/usr/share/DisplayCAL",
        "/usr/share/doc/DisplayCAL",
        f"/usr/share/doc/DisplayCAL-{VERSION_STRING}",
        "/usr/share/doc/displaycal",
        "/usr/share/doc/packages/DisplayCAL",
        "/usr/share/icons/hicolor",
        "/usr/share/pop/DisplayCAL",
        "/usr/share/pop/doc/DisplayCAL",
        f"/usr/share/pop/doc/DisplayCAL-{VERSION_STRING}",
        "/usr/share/pop/doc/displaycal",
        "/usr/share/pop/doc/packages/DisplayCAL",
        "/usr/share/pop/icons/hicolor",
        "/var/lib/DisplayCAL",
        "/var/lib/doc/DisplayCAL",
        f"/var/lib/doc/DisplayCAL-{VERSION_STRING}",
        "/var/lib/doc/displaycal",
        "/var/lib/doc/packages/DisplayCAL",
        "/var/lib/flatpak/exports/share/DisplayCAL",
        "/var/lib/flatpak/exports/share/doc/DisplayCAL",
        f"/var/lib/flatpak/exports/share/doc/DisplayCAL-{VERSION_STRING}",
        "/var/lib/flatpak/exports/share/doc/displaycal",
        "/var/lib/flatpak/exports/share/doc/packages/DisplayCAL",
        "/var/lib/flatpak/exports/share/icons/hicolor",
        "/var/lib/icons/hicolor",
    ]
    assert sorted(config.data_dirs) == sorted(expected_data_dirs)