MCPcopy Create free account
hub / github.com/idank/explainshell / test_extract_expands_at_file

Method test_extract_expands_at_file

tests/test_manager.py:2508–2541  ·  view source on GitHub ↗

@file arg is expanded to the file's contents and reaches the classifier.

(
        self,
        _mock_source: MagicMock,
        _mock_link: MagicMock,
        _mock_sha: MagicMock,
    )

Source from the content-addressed store, hash-verified

2506 side_effect=lambda p: f"fake/release/1/{os.path.basename(p)}",
2507 )
2508 def test_extract_expands_at_file(
2509 self,
2510 _mock_source: MagicMock,
2511 _mock_link: MagicMock,
2512 _mock_sha: MagicMock,
2513 ) -> None:
2514 """@file arg is expanded to the file's contents and reaches the classifier."""
2515 with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
2516 f.write("/fake/echo.1.gz\n")
2517 f.flush()
2518 list_path = f.name
2519
2520 try:
2521 with _temp_db() as db_path:
2522 Store.create(db_path).close()
2523 runner = CliRunner()
2524 with self.assertLogs("explainshell.manager", level="INFO") as cm:
2525 result = runner.invoke(
2526 cli,
2527 [
2528 "--db",
2529 db_path,
2530 "extract",
2531 "--mode",
2532 "llm:test-model",
2533 "--dry-run",
2534 f"@{list_path}",
2535 ],
2536 )
2537
2538 self.assertEqual(result.exit_code, 0, result.output)
2539 self.assertIn("fake/release/1/echo.1.gz", "\n".join(cm.output))
2540 finally:
2541 os.unlink(list_path)
2542
2543 @patch("explainshell.extraction.common.gz_sha256", side_effect=lambda p: p)
2544 @patch("os.path.islink", return_value=False)

Callers

nothing calls this directly

Calls 3

_temp_dbFunction · 0.85
closeMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected