mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-28 21:29:14 +01:00
Fix ruff in credit help test
Todo: 7808ee0a Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2e0111724b
commit
e398f47740
@ -3,9 +3,8 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from kuhy_credit import credit_line
|
from kuhy_credit import credit_line
|
||||||
|
import pytest
|
||||||
|
|
||||||
MODULES_WITH_CLI = [
|
MODULES_WITH_CLI = [
|
||||||
"wake_alarm._audit",
|
"wake_alarm._audit",
|
||||||
@ -17,24 +16,22 @@ MODULES_WITH_CLI = [
|
|||||||
|
|
||||||
|
|
||||||
def _run_help(module: str) -> str:
|
def _run_help(module: str) -> str:
|
||||||
"""Run `python -m <module> --help` and return stdout."""
|
"""Run `python -m <module> --help` and return stdout.
|
||||||
|
|
||||||
|
Never falls back to a bare run: `_trigger` without --help could start the
|
||||||
|
real morning routine. argparse exits 0 on --help, so check=True holds.
|
||||||
|
"""
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[sys.executable, "-m", module, "--help"],
|
[sys.executable, "-m", module, "--help"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
check=True,
|
||||||
if result.returncode != 0:
|
|
||||||
# Some modules need a subcommand; mode_parser is one. Try without --help.
|
|
||||||
result = subprocess.run(
|
|
||||||
[sys.executable, "-m", module],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
)
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("module", MODULES_WITH_CLI)
|
@pytest.mark.parametrize("module", MODULES_WITH_CLI)
|
||||||
def test_help_ends_with_credit_line(module: str):
|
def test_help_ends_with_credit_line(module: str) -> None:
|
||||||
"""The --help output must end with credit_line()."""
|
"""The --help output must end with credit_line()."""
|
||||||
help_text = _run_help(module)
|
help_text = _run_help(module)
|
||||||
assert help_text.endswith(credit_line() + "\n"), (
|
assert help_text.endswith(credit_line() + "\n"), (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user