File: test_cli.py

package info (click to toggle)
trove-classifiers 2026.1.14.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: python: 1,096; makefile: 25
file content (32 lines) | stat: -rw-r--r-- 1,043 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
"""test_cli.py - Tests to confirm that the CLI works and that both running the module and
calling the entry point produce equivalent output.
"""

import subprocess
import sys
from pathlib import Path

BINDIR = Path(sys.executable).parent


def test_module_run():
    """Simple test for no error when running the module. Output is not validated."""
    subprocess.check_call([sys.executable, "-m", "trove_classifiers"])


def test_entry_point():
    """Simple test for no error when calling the entry point. Output is not validated."""
    subprocess.check_call(f"{BINDIR}/trove-classifiers")


def test_module_run_is_entry_point():
    """Compare that module run output is the same as entry point output."""
    module_run_proc = subprocess.run(
        [sys.executable, "-m", "trove_classifiers"],
        capture_output=True,
        encoding="utf-8",
    )
    entry_point_proc = subprocess.run(
        f"{BINDIR}/trove-classifiers", capture_output=True, encoding="utf-8"
    )
    assert module_run_proc.stdout == entry_point_proc.stdout