Skip to content

Commit 618ddd5

Browse files
author
Ziang Zhang
committed
test: fix help docs test by adding _import_module to fake kernel
The test_run_help_prints_docstring_for_known_command test was failing because the fake kernel lacked a _import_module method, causing the module import to fail silently and fall through to the error message. Add a working _fake_import_module that uses importlib to resolve the module path, allowing run_help to read and print the docstring.
1 parent 7bbc77e commit 618ddd5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/test_help_docs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
from __future__ import annotations
22

3+
import importlib
34
from types import SimpleNamespace
45

56
from trushell.commands.core import run_help
67

78

89
def test_run_help_prints_docstring_for_known_command(monkeypatch, capsys):
10+
def _fake_import_module(path: str):
11+
module = importlib.import_module(path.replace("/", ".").removesuffix(".py"))
12+
return module
13+
914
fake_kernel = SimpleNamespace(
1015
registry={
1116
"settings": {
1217
"path": "trushell/commands/settings.py",
1318
"function": "run_settings",
1419
}
15-
}
20+
},
21+
_import_module=_fake_import_module,
1622
)
1723

1824
monkeypatch.setattr("trushell.core.trukernel.get_kernel", lambda: fake_kernel)

0 commit comments

Comments
 (0)