File: test_psjoin.py

package info (click to toggle)
psutils 3.3.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,280 kB
  • sloc: python: 2,984; makefile: 28
file content (50 lines) | stat: -rw-r--r-- 1,061 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
45
46
47
48
49
50
"""psjoin tests.

Copyright (c) Reuben Thomas 2023.
Released under the GPL version 3, or (at your option) any later version.
"""

from contextlib import redirect_stdout
from pathlib import Path

from testutils import Case, GeneratedInput, file_test, make_tests

from psutils.command.psjoin import psjoin


FIXTURE_DIR = Path(__file__).parent.resolve() / "test-files"


def psjoin_to_file(args: list[str]) -> None:
    output_file = args.pop()
    args.append(args[-1])
    with open(output_file, "w", encoding="utf-8") as f:
        with redirect_stdout(f):
            psjoin(args)


pytestmark = make_tests(
    psjoin_to_file,
    Path(__file__).parent.resolve() / "test-files",
    Case(
        "1-2",
        [],
        GeneratedInput("a4", 1),
    ),
    Case(
        "1-2-even",
        ["--even"],
        GeneratedInput("a4", 1),
    ),
    Case(
        "1-2-nostrip",
        ["--nostrip"],
        GeneratedInput("a4", 1),
    ),
    Case(
        "1-2-save",
        ["--save"],
        GeneratedInput("a4", 1),
    ),
)
test_psjoin = file_test