diff --git a/src/urdf_calibration/tests/conftest.py b/src/urdf_calibration/tests/conftest.py deleted file mode 100644 index e1e17ec..0000000 --- a/src/urdf_calibration/tests/conftest.py +++ /dev/null @@ -1,84 +0,0 @@ -"""Shared read-only synthetic input; mutating tests must copy their records.""" - -import pytest - - -# Keep compatibility in one catalog, without moving modules imported as fixtures. -TIERS = { - "legacy": set("""acquisition alignment_view calibrated_joint_state_bridge core diagnostics - full_hand g20_right_product golden_regression l6_right_profile o12_full_hand_zero - o12_observation_resolution o12_right_profile o12_thumb_pnp o6_right_profile - offline_replay sample_schema storage trajectory urdf_comparison urdf_zero zero_calibration - resume_v2""".split()), - "replay": set("""recorded_diagnostic_replay recorded_side_preparation o12_recorded_replay - spatial_solve_order shared_tag_pose_bridge shared_zero_conditioning shared_pose_conditioning - measured_transfer transferred_hinge_geometry o30_side_observer resumed_image_reference - final_image_sources feedback_reversal_progress native_position_feedback - preparation_admission""".split()), - "integration": set("""all_model_artifact_pipeline all_view_image_acceptance axis_line_gauge - bounded_mimic_approximation calibration_coordinator cad_image_geometry - directional_command_mapping dual_mapping final_image_holdout frozen_candidate_selection - frozen_tag_replay image_model_selection image_motion_live_flow independent_urdf_export - json_urdf_rebuild measured_finalization measured_transfer_finalization measured_zero_mapping - o30_artifacts o6_tag_installation partial_o30_calibration parallel_image_replay - production_image_motion profile_finalization relative_standard_urdf single_pass_capture - transfer_artifact_contract unified_ros_host""".split()), -} - - -def pytest_addoption(parser): - parser.addoption("--timings-json", help="Write durations and outcomes for this selected run to JSON") - - -def pytest_collection_modifyitems(items): - for item in items: - if any(item.get_closest_marker(name) for name in ("quick", *TIERS)): - continue - name = item.path.stem.removeprefix("test_") - tier = next((tier for tier, names in TIERS.items() if name in names), "quick") - item.add_marker(getattr(pytest.mark, tier)) - - -def pytest_configure(config): - import time - config._calibration_started = time.perf_counter() - config._calibration_timings = {} - config._calibration_source_sha256 = None - if config.getoption("--timings-json"): - import hashlib - from pathlib import Path - root = Path(__file__).resolve().parents[1] - digest = hashlib.sha256() - for path in sorted((*root.rglob("*.py"), *root.rglob("*.yaml"))): - digest.update(str(path.relative_to(root)).encode()) - digest.update(path.read_bytes()) - config._calibration_source_sha256 = digest.hexdigest() - - -@pytest.hookimpl(hookwrapper=True) -def pytest_runtest_makereport(item, call): - report = (yield).get_result() - result = item.config._calibration_timings.setdefault(item.nodeid, { - "tier": next(name for name in ("quick", *TIERS) if item.get_closest_marker(name)), - "phases": {}}) - result["phases"][report.when] = {"seconds": report.duration, "outcome": report.outcome} - - -def pytest_sessionfinish(session): - path = session.config.getoption("--timings-json") - if path: - import json - import time - from pathlib import Path - output = Path(path) - output.parent.mkdir(parents=True, exist_ok=True) - output.write_text(json.dumps({"exit_status": int(session.exitstatus), - "elapsed_seconds": time.perf_counter()-session.config._calibration_started, - "source_sha256": session.config._calibration_source_sha256, - "tests": session.config._calibration_timings}, indent=2) + "\n") - - -@pytest.fixture(scope="session") -def o30_capture(): - from o30_capture_fixture import synthetic_capture - return synthetic_capture()