Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Cursor PytestNew to Visual Studio Code? Get it now.
Cursor Pytest

Cursor Pytest

Arun Dev

|
74 installs
| (0) | Free
PyCharm-style run and debug buttons for Python tests in VS Code/Cursor.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Cursor Pytest: PyCharm-Style Test Runner for VS Code & Cursor

Visual Studio Marketplace Version Visual Studio Marketplace Downloads License: MIT

Cursor Pytest brings the beloved PyCharm-style inline Run/Debug buttons to VS Code and Cursor, making Python development and testing more intuitive and efficient. Run or debug individual test functions with a single click, just like in JetBrains IDEs!

✨ Features

🎯 Inline CodeLens Buttons

  • Run Test (▶️): Execute individual test functions with one click
  • Debug Test (🐞): Debug specific tests with VS Code's integrated debugger
  • Configure Args (⚙️): Quick access to pytest argument configuration

📱 Status Bar Integration

  • Quick Run/Debug buttons in the status bar for active Python files
  • Automatically show/hide based on file type

📁 Python Files Explorer

  • Dedicated sidebar view to browse all Python files in your workspace
  • Direct run/debug actions from the file tree
  • Automatic exclusion of virtual environments

🧪 Test Support

  • Pytest Integration: Full support for pytest framework
  • Custom Arguments: Configure additional pytest arguments
  • VS Code Debugger: Native VS Code debugging without hanging on test failures
  • Test Discovery: Automatic detection of test functions using naming conventions

📋 Context Menus

  • Right-click context menu options for Python files
  • Test-specific menu items when cursor is on test functions
  • Quick configuration access

🚀 Installation

From VS Code Marketplace

  1. Open VS Code or Cursor
  2. Navigate to Extensions view (Ctrl+Shift+X / Cmd+Shift+X)
  3. Search for "Cursor Pytest"
  4. Click Install

From VSIX File

  1. Download the latest .vsix file from the Releases page
  2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  3. Type Extensions: Install from VSIX...
  4. Select your downloaded file

📖 Usage

Running Individual Tests

  1. Open a Python test file (e.g., test_example.py)
  2. Locate test functions (functions starting with test_)
  3. Click the buttons that appear above each test function:
    • ▶️ Run Test: Execute the test
    • 🐞 Debug Test: Debug with breakpoints
    • ⚙️ Pytest Args: Configure arguments

Status Bar Controls

When a Python file is active, use the status bar buttons:

  • $(play) Run: Execute the entire current file
  • $(bug) Debug: Debug the entire current file

Python Files Explorer

  1. Open the Explorer panel
  2. Find the "Python Files" section
  3. Browse and click on any Python file to open it
  4. Use inline run/debug buttons for quick execution

Command Palette

Access all functionality via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):

  • Run Python File
  • Debug Python File
  • Modify Run Configuration...
  • Modify Additional Pytest Arguments...

⚙️ Configuration

Open VS Code/Cursor settings and search for "Cursor Pytest" or manually edit your settings.json:

{
  "cursor-pytest.pythonPath": "python",
  "cursor-pytest.runArgs": [],
  "cursor-pytest.additionalArgs": "--alluredir=allure-results -x"
}

Configuration Options

Setting Type Default Description
cursor-pytest.pythonPath string "python" Path to Python executable
cursor-pytest.runArgs array [] Arguments for running Python scripts
cursor-pytest.additionalArgs string "" Additional pytest arguments (e.g., --alluredir=reports -v --tb=short)

Example Configurations

Basic pytest with verbose output:

{
  "cursor-pytest.additionalArgs": "-v --tb=short"
}

With coverage reporting:

{
  "cursor-pytest.additionalArgs": "--cov=src --cov-report=html --cov-report=term"
}

With Allure reporting:

{
  "cursor-pytest.additionalArgs": "--alluredir=allure-results -v"
}

🛠️ Requirements

  • Python 3.6+ installed and accessible in PATH
  • pytest for test execution:
    pip install pytest
    

Optional Dependencies

For enhanced functionality, consider installing:

pip install pytest-cov        # Code coverage
pip install pytest-xdist      # Parallel test execution
pip install allure-pytest     # Allure reporting

🔧 Troubleshooting

Tests Not Detected

  • Ensure test functions start with test_ (e.g., def test_my_function():)
  • Check that pytest is installed: pip install pytest
  • Verify Python path in settings if using virtual environments

Virtual Environment Issues

Set the correct Python path:

{
  "cursor-pytest.pythonPath": "/path/to/your/venv/bin/python"
}

Custom Test Discovery

If using custom test patterns, configure pytest in pytest.ini or pyproject.toml:

[tool:pytest]
python_files = test_*.py *_test.py
python_functions = test_*
python_classes = Test*

🏗️ Development

Project Structure

.
├── src/
│   └── extension.ts          # Main extension logic
├── package.json              # Extension manifest
├── tsconfig.json            # TypeScript configuration
├── icon.png                 # Extension icon
└── README.md               # This file

Building from Source

  1. Clone the repository:

    git clone <repository-url>
    cd pycharm-style-runner
    
  2. Install dependencies:

    npm install
    
  3. Compile TypeScript:

    npm run compile
    
  4. Package the extension:

    vsce package
    

Key Components

  • TestCodeLensProvider: Provides inline run/debug buttons above test functions
  • PythonFilesProvider: Powers the Python Files explorer tree view
  • Status Bar Integration: Manages run/debug buttons in the status bar
  • Command Registration: Handles all extension commands and menu items

🛠️ Changelog

v0.3.0 (Latest - Rebranded)

  • 🎯 Rebranded: Changed extension name to "Cursor Pytest"
  • ✅ Core Features: Run Test, Debug Test, Configure Args
  • 🐛 Fixed: Debug hanging completely resolved (no --pdb flag)
  • 🚀 Clean UI: Simple, focused interface with essential controls
  • ⚡ Fast: Lightweight extension with minimal overhead

Previous Versions (as CurVsTest)

  • v0.6.0: Simplified version with core features only
  • v0.5.3: Complex test status tracking (removed for simplicity)
  • v0.5.2: Debug hanging fixes
  • v0.5.1: Enhanced pytest argument integration
  • v0.5.0: Initial debug improvements

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by the excellent test running experience in JetBrains PyCharm
  • Built with the VS Code Extension API
  • Uses the pytest framework for test execution

Enjoy a more productive Python testing experience! 🐍✨

For support, feature requests, or bug reports, please visit the GitHub repository or leave a review on the VS Code Marketplace.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft