Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
* Remove legacy *main.py* and introduce *pkgmgr* module entry via *python -m pkgmgr* * Add ***main**.py* as the canonical entry point delegating to the CLI * Export *PYTHONPATH=src* in Makefile to ensure reliable imports in dev and CI * Update setup scripts (venv & nix) to use module execution * Refactor all E2E tests to execute the real module entry instead of file paths This aligns pkgmgr with standard Python packaging practices and simplifies testing, setup, and execution across environments. https://chatgpt.com/share/693c9056-716c-800f-b583-fc9245eab2b4
65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import runpy
|
|
import sys
|
|
import unittest
|
|
|
|
from test_version_commands import PROJECT_ROOT
|
|
|
|
|
|
class TestIntegrationListCommands(unittest.TestCase):
|
|
"""
|
|
Integration tests for `pkgmgr list` with the new selection and
|
|
description behaviour.
|
|
"""
|
|
|
|
def _run_pkgmgr(self, args: list[str], cwd: str | None = None) -> None:
|
|
cmd_repr = "pkgmgr " + " ".join(args)
|
|
original_argv = list(sys.argv)
|
|
original_cwd = os.getcwd()
|
|
|
|
try:
|
|
if cwd is not None:
|
|
os.chdir(cwd)
|
|
|
|
# Simulate: pkgmgr <args...>
|
|
sys.argv = ["pkgmgr"] + args
|
|
|
|
try:
|
|
runpy.run_module("pkgmgr", run_name="__main__")
|
|
except SystemExit as exc:
|
|
code = exc.code if isinstance(exc.code, int) else str(exc.code)
|
|
if code != 0:
|
|
print()
|
|
print(f"[TEST] Command : {cmd_repr}")
|
|
print(f"[TEST] Working directory: {os.getcwd()}")
|
|
print(f"[TEST] Exit code : {code}")
|
|
raise AssertionError(
|
|
f"{cmd_repr!r} failed with exit code {code}. "
|
|
"Scroll up to inspect the output printed before failure."
|
|
) from exc
|
|
finally:
|
|
os.chdir(original_cwd)
|
|
sys.argv = original_argv
|
|
|
|
def test_list_all_repositories(self) -> None:
|
|
"""
|
|
`pkgmgr list --all` should successfully print the summary table.
|
|
"""
|
|
self._run_pkgmgr(["list", "--all"], cwd=PROJECT_ROOT)
|
|
|
|
def test_list_all_with_description(self) -> None:
|
|
"""
|
|
`pkgmgr list --all --description` should print the table plus the
|
|
detailed section for each repository.
|
|
"""
|
|
self._run_pkgmgr(["list", "--all", "--description"], cwd=PROJECT_ROOT)
|
|
|
|
def test_list_with_string_filter(self) -> None:
|
|
"""
|
|
`pkgmgr list --string pkgmgr` exercises the new string-based
|
|
selection logic on top of the defaults + user config.
|
|
"""
|
|
self._run_pkgmgr(["list", "--string", "pkgmgr"], cwd=PROJECT_ROOT)
|