mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 18:18:08 +00:00
fix: run the module when the docsgpt command is not on PATH
Refusing to write the service units when `docsgpt` is not on PATH was wrong. A package installed in a virtualenv is runnable whether or not its console script is on PATH, and CI runs pytest as `python -m pytest`, where argv[0] is a module file: the refusal failed thirteen native tests there. The launcher now prefers the command on PATH, resolved to an absolute path since PATH can hold relative entries, then an argv[0] that can be executed, and otherwise this interpreter with `-m docsgpt`, which works wherever the package is importable. `python -m docsgpt` became an entrypoint of its own and has a test that runs it.
This commit is contained in:
1 parent
f9f52e99f0
commit
a96734da07
5 files changed
+53
-20
No files matched your search
@@ -34,6 +34,16 @@ class TestTopLevel:
|
||||
subprocess.run([sys.executable, "-c", code], cwd=Path(__file__).resolve().parents[1], check=True)
|
||||
|
||||
|
||||
class TestModuleEntrypoint:
|
||||
def test_python_m_docsgpt_runs_the_cli(self):
|
||||
"""`python -m docsgpt` is what a native service falls back to when the script is not on PATH."""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "docsgpt", "--version"],
|
||||
cwd=Path(__file__).resolve().parents[1], capture_output=True, text=True, check=True,
|
||||
)
|
||||
assert result.stdout.strip() == f"docsgpt {__version__}"
|
||||
|
||||
|
||||
class TestHome:
|
||||
@staticmethod
|
||||
def _installed(monkeypatch, tmp_path):
|
||||
|
||||
Reference in new issue
Block a user