Orchestrata Ultimate › Tests › Reference › test_orchestrata_ast_env_access

Tests reference — tests/test_orchestrata_ast_env_access.py

Module of tests, split out because the directory page would be too large.

Prose pending.

tests/test_orchestrata_ast_env_access.py

source · 18 tests · 313 lines

Tests for AST-snapshot env-access + import-line capture.

Kind Name Line Description
class TestEnvAccessCapture 66
method TestEnvAccessCapture.test_every_form_of_env_read_is_captured 67
method TestEnvAccessCapture.test_a_subscript_read_is_distinguishable_from_get 79 The whole of RUL-003 turns on this distinction: a bare subscript is
method TestEnvAccessCapture.test_a_computed_key_is_reported_unknown_not_guessed 90 os.environ.get(name) has no literal key. A rule that invented
method TestEnvAccessCapture.test_reads_inside_function_bodies_are_captured 100 RUL-003 applies at any nesting depth; the module walk that builds
method TestEnvAccessCapture.test_a_module_with_no_env_access_reports_none 107
method TestEnvAccessCapture.test_forms_are_classified 121
class TestImportLines 130
method TestImportLines.test_every_import_carries_its_source_line 131
method TestImportLines.test_a_relative_import_reports_a_line_a_rule_can_cite 139 no_relative_import reports file:line. Line 0 is not a location.
class TestRoundTrip 152
method TestRoundTrip.test_env_accesses_survive_serialize_and_back_as_objects 153 The snapshot is written as JSON and read back; a field that
method TestRoundTrip.test_import_lines_survive_the_round_trip 166
class TestScopedImports 204 Nested imports reach the snapshot, labelled with the scope they run in.
method TestScopedImports.test_a_function_local_import_is_captured_with_its_owner 221
method TestScopedImports.test_a_class_body_import_runs_at_import_time 233
method TestScopedImports.test_a_class_nested_in_a_function_stays_lazy 240 The enclosing def wins: that class body only runs when helper() does.
method TestScopedImports.test_a_type_checking_import_is_labelled_not_dropped 248
method TestScopedImports.test_an_optional_dependency_import_is_module_scope_but_guarded 257 try: import ujson executes at import time, but is allowed to fail.
method TestScopedImports.test_a_plain_module_import_is_unguarded_module_scope 267
method TestScopedImports.test_scope_and_owner_survive_the_round_trip 277
method TestScopedImports.test_a_lazy_import_is_not_an_import_time_dependency 286 dependency_graph feeds find-cycles, and a lazy import is the