Orchestrata Ultimate › Tests › Reference › claude › test_module_context
Tests reference — tests/claude/test_module_context.py
Module of tests/claude, split out because the directory page would be too large.
Prose pending.
tests/claude/test_module_context.py
source · 95 tests · 1662 lines
Tests for
claude/tools/module_context.py— the tool that injects a
| Kind | Name | Line | Description |
|---|---|---|---|
| function | test_project_root_finds_git_marker |
155 | |
| function | test_project_root_finds_pyproject_marker |
166 | |
| function | test_project_root_no_marker_falls_back_to_parent |
176 | |
| function | test_module_name_simple_relative_path |
191 | |
| function | test_module_name_strips_src_and_primary_package |
198 | |
| function | test_module_name_strips_src_without_primary_match_keeps_package |
209 | |
| function | test_module_name_strips_init_suffix |
224 | |
| function | test_module_name_path_outside_root_falls_back_to_stem |
231 | |
| function | test_primary_package_no_src_dir_returns_none |
241 | |
| function | test_primary_package_src_with_no_packages_returns_none |
246 | |
| function | test_primary_package_matches_root_name |
253 | |
| function | test_primary_package_falls_back_to_largest_package |
263 | |
| function | test_parse_module_syntax_error_returns_error_dict |
282 | |
| function | test_parse_module_unreadable_file_returns_error_dict |
290 | |
| function | test_parse_module_full_signature_surface |
297 | Exercises _sig's every branch: posonly args, defaults, *args, |
| function | test_parse_module_imports_level0_only |
363 | |
| function | test_parse_module_no_classes_or_functions_still_parses |
383 | |
| function | test_snapshot_path_prefers_named_snapshot |
397 | |
| function | test_snapshot_path_falls_back_to_default |
404 | |
| function | test_stale_in_scope_no_snapshot_all_files_stale |
411 | |
| function | test_stale_in_scope_newer_file_is_stale_older_is_not |
419 | |
| function | test_stale_in_scope_missing_file_is_skipped |
434 | |
| function | test_refresh_snapshot_never_shells_out_to_uv_run |
449 | uv run here cost 46% of the suite AND stalled every prompt. |
| function | test_refresh_snapshot_fails_fast_without_an_entry_point |
494 | A directory with no .venv/bin/ast-sync cannot be refreshed. |
| function | test_refresh_snapshot_reports_an_unrunnable_entry_point |
518 | The OSError branch: the entry point exists but cannot be executed. |
| function | test_infer_scope_explicit_path_in_text |
567 | |
| function | test_infer_scope_duplicate_explicit_path_not_added_twice |
576 | |
| function | test_infer_scope_caps_at_five_explicit_paths_breaks_before_prolog |
584 | 5 explicit paths fill files to the cap BEFORE the term loop even |
| function | test_infer_scope_prolog_failure_continues_past_term |
600 | L331-332: prolog() returning ok=False for a term -> continue to the |
| function | test_infer_scope_find_symbol_against_real_kb_no_match |
620 | The deliberate exception to "no live KB calls in this block": relies |
| function | test_defect_infer_scope_never_extracts_file_from_find_symbol |
636 | KNOWN DEFECT (reported, not silently patched — see task report): |
| function | test_live_contract_resolves_via_src_primary_package |
705 | |
| function | test_live_contract_unresolvable_returns_empty |
721 | |
| function | test_live_contract_resolves_bare_module_at_root |
728 | |
| function | test_live_contract_resolves_package_init |
736 | |
| function | test_live_contract_private_functions_excluded |
746 | |
| function | test_live_contract_parse_error_returns_empty |
755 | |
| function | test_find_code_intel_no_kb_anywhere_returns_none |
767 | |
| function | test_find_code_intel_own_repo_own_venv |
772 | This real repo genuinely has scripts/code_intel.py + .venv/bin/python |
| function | test_find_code_intel_shared_engine_fallback_when_local_snapshot_exists |
783 | A project with no code_intel.py of its own, but WITH its own AST |
| function | test_find_code_intel_ft_interpreter_fallback_when_own_script_no_venv |
800 | A project with its OWN scripts/code_intel.py but no .venv falls back |
| function | test_find_code_intel_code_intel_cmd_override |
824 | CODE_INTEL_CMD is the module's own designed override seam — driven |
| function | test_cache_key_none_without_snapshot |
849 | |
| function | test_cache_key_present_with_snapshot |
856 | |
| function | test_prolog_real_subprocess_via_code_intel_cmd_override |
879 | Real subprocess execution (echo), real env plumbing: OPENBLAS |
| function | test_prolog_reads_dot_env_file |
901 | |
| function | test_prolog_missing_dot_env_file_is_fine |
918 | No .env file at all -> the OSError from read_text() is swallowed |
| function | test_prolog_nonzero_exit_is_reported_as_failure |
931 | CODE_INTEL_CMD="/bin/false" alone would be a single argv token, |
| function | test_prolog_launch_failure_is_caught |
948 | L505's except (OSError, subprocess.SubprocessError) — a |
| function | test_defect_prolog_indexerror_on_single_token_code_intel_cmd |
966 | KNOWN DEFECT (reported, not silently patched — see task report): |
| function | test_prolog_cache_hit_avoids_second_subprocess_and_reads_same_answer |
998 | First call caches; a second IDENTICAL call (same argv, same |
| function | test_prolog_own_repo_non_shared_branch_real_kb |
1020 | The ONE live call to this real repo's OWN (non-shared) code_intel — |
| function | test_module_contract_unknown_module_returns_empty |
1039 | |
| function | test_module_contract_parses_qname_kind_lines |
1052 | Canned line matches the REAL code_intel.py module-api format |
| function | test_module_contract_prolog_failure_returns_empty |
1073 | |
| function | test_blast_radius_no_exported_symbols |
1081 | No _PROJECT seam needed: the "no exported symbols" check (L594) |
| function | test_blast_radius_parses_batch_json_affected |
1097 | Real infra: this repo's own KB, querying a symbol known to exist |
| function | test_blast_radius_synthetic_json_payload_parsing |
1111 | Drives blast_radius() end to end through prolog() with a REAL |
| function | test_blast_radius_excludes_self_from_dependents |
1137 | The module never appears as its own dependent (L642's discard). |
| function | test_blast_radius_invalid_json_payload_is_swallowed |
1157 | L616-618: ok=True (the query subprocess exits 0) but the output is |
| function | test_blast_radius_skips_non_dict_result_entries |
1180 | L624-625: a batch payload whose "results" dict has a NON-dict value |
| function | test_blast_radius_not_ok_but_known_symbol_message_still_answered |
1205 | L639-640: prolog() itself fails (nonzero exit — ok=False), but |
| function | test_render_parse_error_short_circuits |
1237 | |
| function | test_render_full_module_no_kb_degrades_gracefully |
1247 | |
| function | test_render_blast_radius_section_with_real_dependents |
1276 | L742-748: dependents found -> the "N modules break if this changes" |
| function | test_render_no_classes_or_functions_message |
1305 | |
| function | test_render_internal_dependency_resolved_via_live_source |
1314 | |
| function | test_render_unresolvable_dependency_message |
1331 | A BARE unknown name (no dot) is classified EXTERNAL by |
| function | test_render_more_than_eight_project_imports_truncates |
1347 | |
| function | test_render_more_than_eight_exported_symbols_truncates |
1359 | |
| function | test_render_path_outside_root_uses_absolute_display |
1369 | L660's except ValueError: path.resolve().relative_to(root.resolve()) |
| function | test_render_fresh_snapshot_no_refresh_needed |
1383 | Snapshot NEWER than the target file -> stale_in_scope() returns |
| function | test_render_more_than_ten_methods_truncates_class_diagram |
1402 | |
| function | test_render_stale_snapshot_triggers_refresh_attempt |
1412 | A snapshot OLDER than the target file, in a project that IS its own |
| function | test_render_truncates_when_over_max_bytes |
1445 | |
| function | test_render_rag_block_failure_is_swallowed |
1455 | The RAG import/query block is wrapped in a bare `except Exception: |
| function | test_looks_external_stdlib_module |
1473 | |
| function | test_looks_external_project_dir_is_internal |
1479 | |
| function | test_looks_external_project_src_dir_is_internal |
1485 | |
| function | test_looks_external_third_party_dotted_name_is_internal_by_default |
1491 | A dotted external name with no local dir match falls to the final |
| function | test_looks_external_bare_unknown_name_no_local_file_is_external |
1503 | |
| function | test_render_new_file_package_does_not_exist |
1515 | |
| function | test_render_new_file_no_siblings |
1523 | |
| function | test_render_new_file_lists_sibling_public_api |
1532 | |
| function | test_render_new_file_skips_sibling_with_parse_error |
1544 | |
| function | test_render_new_file_skips_sibling_with_nothing_public |
1553 | |
| function | test_render_new_file_truncates_beyond_sibling_limit |
1562 | |
| function | test_render_new_file_path_outside_root_uses_absolute |
1572 | |
| function | test_main_missing_file_without_new_file_flag_errors |
1601 | |
| function | test_main_missing_file_with_new_file_flag_succeeds |
1608 | |
| function | test_main_existing_file_renders_and_exits_zero |
1615 | |
| function | test_main_json_flag_wraps_output |
1623 | |
| function | test_main_json_flag_with_new_file |
1633 | |
| function | test_main_explicit_root_overrides_auto_detection |
1641 | |
| function | test_main_max_bytes_flag_truncates |
1656 |