Pytest Run Assistant is a Visual Studio Code extension that adds handy CodeLens buttons above each pytest test function and test class. It allows you to run, debug, and configure launch arguments for each test individually.
- CodeLens buttons for test functions and classes (or name-main idiom):
- ▶ Run
- 🐞 Debug
- ⚙️ Args – configure launch arguments for a specific test
- Stores individual launch arguments per test (or
if __name__ == "__main__":construction) - Runs tests using
pytestin the integrated terminal - Debugs using VS Code's built-in debugger and
debugpy - Supports configuration for Python path
- Forced save file before run (for debug is default behavior)
Add the following to your settings.json:
{
"pythonFuncRunner.pythonPath": "/path/to/python",
"pythonFuncRunner.extraRunArgs": "-rpP",
}or
just find in settings @ext:Pependuez.pytest-run-assistant
The easiest way — if you're using Poetry — is to run:
poetry env info
Look for the Executable: field in the output (works on all systems).
Alternatively, you can use the following commands to find the Python executable in an activated environment: macOS / Linux:
which pythonWindows (Command Prompt):
where pythonWindows (PowerShell):
Get-Command pythonYou can also try locating the executable manually in .venv or .pyenv directories under your home folder.
- Python environment with
pytestinstalled - VS Code Python extension (for debugging support)
The extension parses Python files and adds CodeLens above test functions (def test_...) and test classes (class Test...). Clicking:
- Run: runs the test using pytest in the terminal
- Debug: starts a debug session with debugpy
- Args: allows you to define test-specific launch arguments
You can find the source code on GitHub: https://github.com/pependuez/pytest-run-assistant
I’m open to suggestions, feature requests, and feedback of any kind — including criticism. If you find a bug, have an idea, or just want to share your experience, feel free to open an issue or discussion on GitHub. Also, if you find this extension useful, a star or a rating on the marketplace is always appreciated!