Orchestrata Ultimate › Tests › Reference › scripts › test_test_review_tool

Tests reference — tests/scripts/test_test_review_tool.py

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

Prose pending.

tests/scripts/test_test_review_tool.py

source · 136 tests · 2159 lines

Tests for scripts/test-review.py — the T-rules test-file reviewer.

Covers: core.threading.pytest_live_observer

Kind Name Line Description
function test_find_test_files_matches_test_prefix_file 141
function test_find_test_files_matches_test_suffix_file 148
function test_find_test_files_includes_explicit_py_file 155 T21 NEW: explicit .py file is included regardless of naming (for T21 env-key rule).
function test_find_test_files_skips_non_matching_file_in_dir 164 Regular files in directories are skipped (only test-named files scanned).
function test_find_test_files_scans_directory 175
function test_find_test_files_dedupes_across_paths 188
function test_check_file_syntax_error 200
function test_check_file_clean_file_has_no_issues 208
function test_t1_import_unittest_mock 223
function test_t1_import_from_unittest_mock 228
function test_t1_import_from_mock_package 234
function test_t1_bare_name_usage 239
function test_t2_fake_class 253
function test_t2_stub_and_dummy_classes 258
function test_t2_normal_class_not_flagged 267
function test_t3_try_except_pass 277
function test_t3_try_except_with_handling_not_flagged 289
function test_t4_module_scope_fixture_attribute_form 306
function test_t4_class_scope_fixture_name_form 317
function test_t4_session_scope_flagged 328
function test_t4_session_scope_with_reasoned_gate_ok_waiver_allowed 339 A reasoned # gate-ok: above the decorator clears scope='session'.
function test_t4_session_scope_with_bare_gate_ok_still_flagged 359 A reason is mandatory — a bare # gate-ok: does not waive.
function test_t4_class_scope_gate_ok_does_not_waive 376 The waiver is scoped to session CONNECTION infra only; class scope stays
function test_t4_function_scope_not_flagged 390
function test_t4_annotated_immutable_module_scope_allowed 396 The harmonized opt-in: annotation directly above the decorator plus a
function test_t4_annotated_module_scope_with_yield_still_flagged 411 A yield means teardown/lifecycle — the annotation does not clear it.
function test_t4_unannotated_module_scope_still_flagged 424 No annotation, no exemption — the categorical default stands.
function test_t4_annotated_session_scope_never_allowed 436 The opt-in exists for module scope only; session stays forbidden.
function test_t5_os_environ_mutation 454
function test_t5_gate_ok_waiver_on_line_above_suppresses 464 A reasoned # gate-ok: adjacent to the mutation waives T5 — the
function test_t5_bare_gate_ok_without_reason_does_not_waive 478 The marker alone is not a waiver — a reason is mandatory, matching
function test_t12_bare_os_environ_read 492
function test_os_environ_get_not_flagged 500
function test_unrelated_subscript_not_flagged 507
function test_t5_t12_comment_line_not_flagged 523
function test_t5_t12_docstring_mention_not_flagged 532
function test_t5_python_source_fixture_string_not_flagged 543
function test_t6_hardcoded_port 569
function test_t6_non_matching_port_not_flagged 575
function test_t6_comment_line_not_flagged 581
function test_t7_pytest_mark_skip 592
function test_t7_pytest_mark_skipif 603
function test_t8_monkeypatch_flagged 619
function test_t8_setenv_allowed 630
function test_t8_delenv_allowed 637
function test_t8_typed_fixture_param_not_flagged 644
function test_t8_docstring_mention_not_flagged 655
function test_t9_module_level_cache 671
function test_t9_module_level_registry_and_instances 677
function test_t9_regular_module_constant_not_flagged 688
function test_t9_pytestmark_is_not_module_state 694 pytestmark is pytest's API, not state this suite owns.
function test_t9_collect_ignore_is_not_module_state 714 collect_ignore/collect_ignore_glob are the same pytest protocol.
function test_t9_exemption_is_name_scoped_not_a_hole 726 The pytest exemption must not blanket-clear the rule.
function test_t10_neo4j_writes_without_namespacing 758
function test_t10_cypher_written_to_a_file_is_fixture_data_not_a_write 768 Cypher handed to a FILE-WRITING call is fixture text for a tool under
function test_t10_cypher_inside_a_python_code_sample_is_not_a_write 786 A string that IS Python source is a sample fed to a checker; the Cypher
function test_t10_write_through_a_helper_parameter_is_still_caught 806 The false-NEGATIVE direction. An allow-list of driver method names (tried
function test_t10_write_through_a_project_named_runner_is_still_caught 824 syncer._run("MERGE ...") is a real write under a name no driver
function test_t10_read_only_cypher_is_not_flagged 837 A query that only reads has nothing to namespace.
function test_t10_read_only_redis_is_not_flagged 848
function test_t10_uuid_namespacing_satisfies_the_rule 857 A per-test uuid4() prefix buys the same collision-freedom the test_id
function test_t10_pipeline_on_a_non_redis_receiver_is_not_flagged 872 This project's own PipelineRunner/volk pipelines match .pipeline(
function test_t10_redis_construction_inside_test_data_is_not_flagged 884 Modules that assert on code samples carry redis.Redis( as a STRING;
function test_t10_test_id_only_in_a_comment_does_not_count 897 A header comment naming the rule is not namespacing. The old check
function test_t10_redis_ops_without_test_id 909
function test_t10_with_test_id_not_flagged 918
function test_t10_conftest_not_flagged 928
function test_t13_relative_import 942
function test_t13_absolute_import_not_flagged 948
function test_t14_async_test_with_marker_not_flagged 959
function test_has_asyncio_mode_reads_real_pyproject 970
function test_t14_async_test_without_marker_relies_on_project_config 980
function test_t15_dash_n_auto_flagged 996
function test_t15_dist_flag_flagged 1008
function test_t20_bare_anyio_mark_flagged 1018 @pytest.mark.anyio under asyncio_mode is the P2.14 defect shape.
function test_t20_called_anyio_mark_flagged 1030 The called form @pytest.mark.anyio(...) must not slip past.
function test_t20_class_level_anyio_mark_flagged 1042 A class-level mark applies to every test in the class, so it counts.
function test_t20_asyncio_mark_not_flagged 1055 The sanctioned plugin's own mark must stay silent, or the rule is noise.
function test_t15_pytest_xdist_word_flagged 1067
function test_t15_bare_string_assignment_not_flagged 1078
function test_t15_ci_yaml_fixture_string_not_flagged 1093
function test_t15_pytest_xdist_worker_env_var_not_flagged 1111
function test_t15_worker_slot_in_invocation_args_not_flagged 1122
function test_t15_bare_name_invocation_flagged 1136
function test_t15_unrelated_call_shape_not_invocation 1148
function test_t15_comment_line_not_flagged 1161
function test_t16_banned_import_flagged 1187
function test_t16_clean_import_not_flagged 1194
function test_t16_import_inside_string_payload_not_flagged 1201
function test_t16_noop_without_banned_libraries_file 1214
function test_t15_docstring_mention_not_flagged 1222
function test_output_text_no_issues_prints_all_clear 1237
function test_output_text_min_severity_error_shows_only_errors 1258
function test_output_text_min_severity_warning_shows_error_and_warning 1274
function test_output_text_min_severity_info_shows_everything 1290
function test_output_text_writes_to_file 1306
function test_main_no_files_found 1338
function test_main_clean_file_returns_zero 1347
function test_main_error_file_returns_one 1358
function test_main_stdout_flag 1367
function test_main_output_file_only 1376
function test_main_stdout_and_output_file_both_written 1388
function test_main_min_severity_error_filters_warnings 1399
function test_main_invalid_min_severity_exits_nonzero 1416
function test_t17_uuid_scoped_label_without_schema_drop_flagged 1456
function test_t17_schema_drop_in_teardown_passes 1463
function test_t17_worker_scoped_label_not_flagged 1472 Fixed per-WORKER labels are bounded by the worker count and keep their
function test_t17_pure_config_factory_not_flagged 1491 A factory that only builds a config owns no lifecycle, so it has no
function test_t19_created_constraint_without_drop_flagged 1532
function test_t19_constraint_dropped_in_teardown_passes 1539
function test_t19_interpolated_label_pairs_through_its_placeholder 1547 An f-string label pairs by placeholder, without resolving the value.
function test_t19_interpolated_label_without_drop_flagged 1561
function test_t19_ddl_asserted_about_is_not_ddl_executed 1574 A generator's expected output is DESCRIPTION, not an executed statement.
function test_t19_index_creation_also_requires_a_drop 1589
function test_t19_node_only_label_is_not_ddl 1598 Creating NODES under a label is swept normally — only DDL persists.
function test_t19_ddl_quoted_in_a_docstring_is_not_ddl_executed 1608 A fixture documenting the DDL it measured is prose, not a statement.
function test_t19_computed_drop_covers_literal_creates 1631 A teardown loop drops by loop variable while creates name literals.
function test_t19_ddl_never_handed_to_a_call_is_data_not_a_statement 1649 A corpus string is Python source stored as data — it executes nothing.
function test_t18_cluster_level_show_databases_is_exempt 1678
function test_t18_one_ordinary_query_removes_the_exemption 1691
function test_t18_computed_query_is_not_provably_cluster_level 1705
function test_t10_gate_ok_cypher_is_data_not_a_write 1718 Cypher a tool SCANS is not Cypher the module executes.
function test_t17_general_retyped_constant_warning 1769 T17-GEN general tier: a retyped non-env UPPER_CASE constant value WARNINGs
function test_t17_general_drift_stays_quiet 1785 T17-GEN general tier: a >=2-token drift against a general constant is NOT
function test_worklist_baseline_downgrades_named_rows 1800 T21-ROUTING ratchet: a named-debt exact-key WARNING downgrades to INFO
function test_t21_drift_detected_error 1819 T21 ERROR: drift literal shares tokens with declared constant.
function test_t21_exact_literal_outside_declaring_module_warning 1844 T21 WARNING: exact literal used outside its declaring module.
function test_t21_correct_usage_no_findings 1867 T21: importing the constant produces 0 findings.
function test_t21_rul003_infra_literal_no_flag 1886 T21: RUL-003 infra keys with no declared constant are not flagged.
function test_t21_incident_regression_orch_test_deadline 1904 T21: incident regression for _child_run_env fabricating ORCH_TEST_DEADLINE.
function test_t21_declaring_module_itself_no_flag 1936 T21: declaring module itself using its own literal → 0 findings.
function test_t21_pytest_durations_file_drift_error 1958 T21 NEW pin: PYTEST_DURATIONS_FILE drift vs REAL registry → ERROR.
function test_t21_pytest_durations_path_exact_warning 1993 T21 NEW pin: PYTEST_DURATIONS_PATH exact literal → WARNING.
function test_t21_any_py_cli_arg_works 2029 T21 NEW pin: reviewing a non-test-named .py → T21 runs, T1-T20 unchanged.
function test_t21_shape_gate_lowercase_dict_key_no_flag 2074 T21: SHAPE gate filters out lowercase dict keys that share tokens with env constants.
function test_t21_d10_t1_t20_skipped_on_non_test_named_py 2107 D10 NEW pin: T1-T20 rules skipped on non-test-named .py; T21 still runs.