TS002: TestsRun

Overview

Property Value
ID TS002
Name TestsRun
Group tests
Severity ERROR

Description

Runs the test suite using pytest and verifies all tests pass.

Having tests that actually run and pass is essential for:

  • Verifying code correctness
  • Catching regressions before release
  • Building confidence in the codebase
  • Enabling safe refactoring

What it checks

The check runs pytest in the package directory and:

  • PASSED: All tests pass (exit code 0)
  • FAILED: One or more tests fail (reports count)
  • NOT_APPLICABLE: pytest is not installed or no tests found

How to fix

Install pytest

pip install pytest
# or
uv add --dev pytest

Run tests locally

pytest
# or with verbose output
pytest -v

Fix failing tests

Review the test output to understand failures:

# Run a specific failing test with more detail
pytest tests/test_module.py::test_name -v --tb=long

Common failure causes

  1. Import errors: Missing dependencies or incorrect paths
  2. Assertion errors: Expected values don’t match actual values
  3. Fixture issues: Test fixtures not set up correctly
  4. Environment differences: Tests depend on specific environment

Configure pytest

Add to pyproject.toml:

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --tb=short"
filterwarnings = [
    "error",
    "ignore::DeprecationWarning",
]

Why ERROR severity?

This check is an ERROR because:

  • Failing tests indicate broken functionality
  • Releases should not happen with failing tests
  • CI/CD pipelines should block on test failures

Configuration

Skip this check

[tool.pycmdcheck]
skip = ["TS002"]

CLI

pycmdcheck --skip TS002