A CLI tool that helps you quickly navigate to test functions in pytest files.
When making fundamental changes to a project, multiple test cases often fail. Instead of manually opening files and searching for each failing test, TestJump allows you to jump directly to the test location 🤷.
Install this tool using pip:
pip install testjumpOr using pipx:
pipx install testjumpOr using uv:
uv tool install testjump- Jump to a test function:
tj tests/test_calculator.py::test_addition- Jump to a test class method:
tj tests/test_user.py::TestUser::test_user_creation- Jump using pytest output (supports FAILED prefix):
tj "FAILED tests/test_user.py::TestUser::test_user_creation - Failed: assertion error"You can use it interactively with a file containing multiple jump points:
for line in $(cat jumppoints.txt); do tj $line; echo "Press any key to continue..."; read; doneTestJump supports different output formats:
- Print location only (useful for scripting):
tj tests/test_calculator.py::test_addition -print
# Output: tests/test_calculator.py:42- JSON output with detailed information:
tj tests/test_calculator.py::test_addition -json
# Output:
# {
# "status": "ok",
# "path": "tests/test_calculator.py",
# "class_name": null,
# "function_name": "test_addition",
# "lineno": 11
# }TestJump uses VS Code by default, but you can configure your preferred editor by setting the TJ_EDITOR environment variable:
# For VS Code (default)
export TJ_EDITOR=vscode
# For Vim
export TJ_EDITOR=vim
# For IntelliJ IDEA
export TJ_EDITOR=idea
# For PyCharm
export TJ_EDITOR=pycharm
# For Neovim
export TJ_EDITOR=nvimAdd this to your .bashrc or .zshrc to make it permanent.
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd testjump
python -m venv .venv
source .venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[dev]'Or if you are using uv:
uv sync --extra devTo run the tests:
uv run pytest .
To help ensure consistent code quality that follows our guidelines, pre-commit may be used. We have git hooks defined which will execute before commit. To install the hooks:
pre-commit install