collect-unmarked-tests

Crates.iocollect-unmarked-tests
lib.rscollect-unmarked-tests
version0.1.0
created_at2025-09-25 15:14:13.231776+00
updated_at2025-09-25 15:14:13.231776+00
descriptionA fast Rust tool to collect Python tests that don't have specific pytest markers
homepagehttps://github.com/stancld/collect-unmarked-tests
repositoryhttps://github.com/stancld/collect-unmarked-tests
max_upload_size
id1854748
size29,459
Daniel Stancl (stancld)

documentation

https://docs.rs/collect-unmarked-tests

README

Collect unmarked pytest

A fast Rust tool to collect Python tests that don't have specific pytest markers.

Usage

# Scan default 'tests' directory
cargo run

# Scan specific directory
cargo run -- src

# Exclude specific markers
cargo run -- --exclude-markers unit,integration,component,slow tests

Build

Prerequisites:

Debug build:

cargo build
./target/debug/collect-unmarked-tests --help

Release build:

cargo build --release
./target/release/collect-unmarked-tests --help

Install locally (optional):

cargo install --path .
collect-unmarked-tests --help

The last command is equivalent to:

pytest -m 'not unit and not integration and not component and not slow' tests

Default excluded markers

  • unit
  • integration
  • component
  • skip
  • slow

The tool scans Python files for test_* functions and excludes those with pytest markers like @pytest.mark.unit or @skip.

Exit codes

  • 0: No unmarked tests found
  • 1: Unmarked tests found (for CI/CD integration)

Using as a pre-commit hook

Add this to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/stancld/collect-unmarked-tests
    rev: v0.1.0  # Use a specific version tag
    hooks:
      - id: collect-unmarked-tests
        args: ['--exclude-markers', 'unit,integration,component,slow']

To scan only specific directories/packages:

repos:
  - repo: https://github.com/stancld/collect-unmarked-tests
    rev: v0.1.0
    hooks:
      - id: collect-unmarked-tests
        args: ['src/mypackage', 'tests/unit']

Or use a local installation:

repos:
  - repo: local
    hooks:
      - id: collect-unmarked-tests
        name: Check for unmarked pytest tests
        entry: collect-unmarked-tests
        language: system
        files: '\.py$'
        args: ['tests']
        pass_filenames: false
Commit count: 4

cargo fmt