How to Run Tests for the RLM Project: A Complete pytest Guide
To run tests for the RLM project, install the development dependencies with uv pip install -e ".[dev]" and execute uv run pytest from the repository root to discover and execute all tests in the tests/ directory.
The RLM (Recursive Language Model) repository by alexzhang13 ships with a comprehensive pytest-based test suite located under the tests/ directory. Running tests for the RLM project validates the core recursion logic, environment handlers, and language model client integrations before deployment.
Prerequisites and Environment Setup
The RLM project targets Python 3.11+ and recommends using uv for fast dependency management. You must install the package in editable mode with development extras to access the testing tools.
Install uv and Create a Virtual Environment
First, install the uv package manager if you do not have it already:
curl -LsSf https://astral.sh/uv/install.sh | sh
Create a fresh virtual environment with Python 3.12 (the recommended version for RLM):
uv init && uv venv --python 3.12
source .venv/bin/activate
Install Development Dependencies
Install RLM in editable mode together with its test extras. The dev extra defined in pyproject.toml pulls in pytest, ruff, and other required tools:
uv pip install -e ".[dev]"
This command makes the rlm package importable from your test files while installing all necessary testing dependencies.
Running the Test Suite
Once dependencies are installed, you can execute the full test suite or target specific modules.
Execute All Tests
Run the complete test suite from the repository root:
uv run pytest
This command discovers all files matching test_*.py or *_test.py under the tests/ directory and executes them. You should see output similar to:
============================= test session starts ==============================
platform linux -- Python 3.12.0, pytest-8.2.2, pluggy-1.5.0
collected 42 items
tests/test_local_repl.py::test_basic_execution PASSED
tests/test_rlm_query.py::test_rlm_query_recursion PASSED
============================== 42 passed in 3.14s ==============================
Run Specific Test Files or Functions
For faster iteration, you can run a single test file or a specific test function using the :: syntax:
# Run a specific test file
uv run pytest tests/test_local_repl.py
# Run a specific test function
uv run pytest tests/test_local_repl.py::test_basic_execution
This targeted approach is useful when debugging specific components like rlm/core/rlm.py or rlm/environments/local_repl.py.
Linting and Code Quality Checks
RLM enforces code style with ruff. Before committing changes, verify formatting and fix auto-correctable issues:
uv run ruff check --fix .
uv run ruff format .
Running these commands ensures your contributions match the project's style guidelines defined in pyproject.toml.
Test Coverage Overview
The RLM test suite validates several critical components across the codebase:
- Core RLM logic – The
RLMclass, recursion handling, and budget/timeout enforcement are tested intests/test_rlm_query.pyandtests/test_depth_metadata.py. - Environment implementations – Correctness of the in-process
LocalREPL(defined inrlm/environments/local_repl.py) as well as isolated Docker and Modal environments are verified intests/test_local_repl.pyandtests/test_ipython_repl.py. - LM handler – Socket protocol compliance and client routing for the TCP-based handler in
rlm/core/lm_handler.pyare checked intests/test_lm_handler.py. - Parsing utilities – Token counting, prompt parsing, and error handling utilities from
rlm/utils/parsing.pyare validated intests/test_parsing.py. - Client wrappers – Sanity checks for OpenAI, Anthropic, Gemini, Portkey, and Azure clients reside in
tests/clients/*.py.
Summary
- Install development dependencies using
uv pip install -e ".[dev]"to pull inpytestandruff. - Execute the full suite with
uv run pytestor target specific tests usinguv run pytest tests/test_local_repl.py::test_basic_execution. - Verify code style with
uv run ruff checkanduv run ruff formatbefore submitting changes. - Key test files cover core logic (
tests/test_rlm_query.py), environments (tests/test_local_repl.py), and client integrations (tests/clients/).
Frequently Asked Questions
What Python version is required to run tests for the RLM project?
The RLM project requires Python 3.11 or higher, though Python 3.12 is recommended for development. Specify the version when creating your virtual environment with uv venv --python 3.12.
How do I run only the tests for a specific module?
Use the file path with uv run pytest followed by the specific test path. For example, uv run pytest tests/test_lm_handler.py runs only the language model handler tests, while uv run pytest tests/test_lm_handler.py::test_socket_protocol runs a single function.
Why does pytest report "module not found" errors?
This typically occurs when you have not installed RLM in editable mode. Ensure you ran uv pip install -e ".[dev]" from the repository root so that the rlm package and its submodules (like rlm.core.rlm and rlm.utils.parsing) are available in your Python path.
How do I fix code style issues before committing changes?
Run uv run ruff check --fix . to automatically correct linting violations and uv run ruff format . to standardize code formatting. These commands ensure your code adheres to the style rules defined in pyproject.toml.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →