"""Tests for cleanup of instrumented test files."""

from codeflash_python.pipeline._orchestrator import (
    find_leftover_instrumented_test_files,
)


def test_find_leftover_instrumented_test_files_python(tmp_path):
    """Test that Python instrumented test files are detected."""
    test_root = tmp_path / "tests"
    test_root.mkdir()

    # Create Python instrumented test files
    py_perf1 = test_root / "test_example__perfinstrumented.py"
    py_perf2 = test_root / "test_foo__perfonlyinstrumented.py"
    py_perf1.touch()
    py_perf2.touch()

    # Create normal Python test file (should NOT be found)
    normal_test = test_root / "test_normal.py"
    normal_test.touch()

    leftover_files = find_leftover_instrumented_test_files(tmp_path)
    leftover_names = {f.name for f in leftover_files}

    assert "test_example__perfinstrumented.py" in leftover_names
    assert "test_foo__perfonlyinstrumented.py" in leftover_names
    assert "test_normal.py" not in leftover_names
    assert len(leftover_files) == 2
