Unit tests pass

1.0 when the generated code plus your hidden tests pass pytest inside a timeout.

pytest_pass.pyverify_environment
def verify_environment(completion: str, metadata: dict | None = None) -> float:
    """Writes completion to solution.py and metadata["tests"] to test_solution.py, runs pytest -q.
    Run untrusted model code in a sandbox (container, VM, or the Tinker cookbook sandbox helpers).
    """
    import re
    import subprocess
    import sys
    import tempfile
    from pathlib import Path

    tests = (metadata or {}).get("tests")
    if not tests:
        return 0.0
    code = completion
    fenced = re.search(r"```(?:python)?\s*(.*?)```", completion, flags=re.S)
    if fenced:
        code = fenced.group(1)
    with tempfile.TemporaryDirectory() as tmp:
        Path(tmp, "solution.py").write_text(code, encoding="utf-8")
        Path(tmp, "test_solution.py").write_text(str(tests), encoding="utf-8")
        try:
            proc = subprocess.run(
                [sys.executable, "-m", "pytest", "-q", "-p", "no:cacheprovider", tmp],
                cwd=tmp,
                timeout=float((metadata or {}).get("timeout", 10)),
                capture_output=True,
                check=False,
            )
        except (FileNotFoundError, subprocess.TimeoutExpired):
            return 0.0
    return 1.0 if proc.returncode == 0 else 0.0
Unit tests pass reward function (Python) — Reinforcement.tech