Skip to content

mattflo/pytest-autofocus

Repository files navigation

pytest-autofocus

Auto-focus plugin for pytest: run only @pytest.mark.focus tests when --auto-focus is set, otherwise run all tests.

Installation

pip install pytest-autofocus

Usage

Mark tests with @pytest.mark.focus:

import pytest

def test_normal():
    pass

@pytest.mark.focus
def test_focused():
    pass

Run with --auto-focus to run only focused tests (if any exist), otherwise run all tests:

pytest --auto-focus

If no tests are marked with @pytest.mark.focus, all tests run normally.

Run without --auto-focus to run all tests:

pytest

pytest-watcher Integration

Use with pytest-watcher for automatic test filtering:

ptw . -- --auto-focus

Requirements

  • Python 3.10+
  • pytest 7.0+

About

Ergonomic test focus for pytest and pytest-watcher

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages