File: test_path.py

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (44 lines) | stat: -rw-r--r-- 1,095 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
from __future__ import annotations

from pathlib import Path

import pytest

from textual.app import App

APP_DIR = Path(__file__).parent


class RelativePathObjectApp(App[None]):
    CSS_PATH = Path("test.tcss")


class RelativePathStrApp(App[None]):
    CSS_PATH = "test.tcss"


class AbsolutePathObjectApp(App[None]):
    CSS_PATH = Path("/tmp/test.tcss")


class AbsolutePathStrApp(App[None]):
    CSS_PATH = "/tmp/test.tcss"


class ListPathApp(App[None]):
    CSS_PATH = ["test.tcss", Path("/another/path.tcss")]


@pytest.mark.parametrize(
    "app_class,expected_css_path_attribute",
    [
        (RelativePathObjectApp, [APP_DIR / "test.tcss"]),
        (RelativePathStrApp, [APP_DIR / "test.tcss"]),
        (AbsolutePathObjectApp, [Path("/tmp/test.tcss")]),
        (AbsolutePathStrApp, [Path("/tmp/test.tcss")]),
        (ListPathApp, [APP_DIR / "test.tcss", Path("/another/path.tcss")]),
    ],
)
def test_css_paths_of_various_types(app_class, expected_css_path_attribute):
    app = app_class()
    assert app.css_path == [path.absolute() for path in expected_css_path_attribute]