Skip to content

refactor: move pytest-cov to lint dependency group - #75

Open
lemenkov wants to merge 1 commit into
ApeWorX:mainfrom
lemenkov:separate_cov_and_lint
Open

refactor: move pytest-cov to lint dependency group#75
lemenkov wants to merge 1 commit into
ApeWorX:mainfrom
lemenkov:separate_cov_and_lint

Conversation

@lemenkov

Copy link
Copy Markdown

What I did

Move pytest-cov from default test options to optional lint group to make it easier for downstream users and packagers to run functional tests without requiring code quality/coverage tools.

fixes: #

How I did it

  • Removed coverage-related flags from [tool.pytest.ini_options] addopts
  • Moved pytest-cov from the test dependency group to the lint group
  • Updated .github/workflows/test.yaml to explicitly pass coverage flags when needed:
    • Added --group lint to the functional test job
    • Added explicit coverage flags: --cov --cov-branch --cov-report=term --cov-report=xml --cov=eip712
    • Removed --no-cov from fuzzing job (no longer needed)

How to verify it

Default pytest run (no coverage):

uv run --group test pytest

This should run tests without attempting to collect coverage.

With coverage (for CI/development):

uv run --group test --group lint pytest --cov=eip712 --cov-branch --cov-report=term

This should work as before, collecting coverage reports.

GitHub Actions:
All existing CI workflows should continue to work unchanged, still collecting coverage as configured.

Why this change?

Currently, pytest-cov runs automatically on every pytest invocation, which creates issues:

  1. Unnecessary dependency: Coverage is a development/CI tool, not required for validating functionality. Users running tests to verify correct installation shouldn't need pytest-cov installed.

  2. Compatibility concerns: Coverage tools can be slow to adapt to new Python versions, potentially blocking early testing with Python alpha/beta releases.

  3. Build system conflicts: Some distribution build systems (like Fedora's RPM packaging) have policies against running code quality tools during package builds, preferring to focus purely on functional testing.

  4. Clearer dependency separation: This aligns with the existing structure where code quality tools (ruff, mypy) are in the lint group, separate from functional test requirements.

Benefits

  • pytest now runs minimal, fast tests by default
  • Developers can still collect coverage by passing flags or installing lint group
  • CI/CD workflows remain unchanged (coverage still collected)
  • Easier for downstream packagers and users to run functional tests
  • Better separation: test dependencies vs. development/quality dependencies

Checklist

  • All changes are completed
  • New test cases have been added (N/A - infrastructure change)
  • Documentation has been updated (N/A - workflow change only)

@lemenkov
lemenkov force-pushed the separate_cov_and_lint branch from 1c7f169 to 31ff80f Compare December 13, 2025 13:12
@lemenkov lemenkov changed the title Move pytest-cov from default test options to optional lint group refactor: move pytest-cov from default test options to optional lint group Dec 13, 2025
Currently, pytest-cov runs automatically on every pytest invocation due
to the coverage flags in [tool.pytest.ini_options] addopts. This creates
several issues for packagers and downstream users:

1. **Unnecessary dependency**: Coverage is a development/CI tool, not
   required for validating functionality. Users running tests to verify
   correct installation shouldn't need pytest-cov installed.

2. **Compatibility concerns**: Coverage tools can be slow to adapt to
   new Python versions, potentially blocking early testing with Python
   alpha/beta releases. Having it as a hard requirement delays adoption.

3. **Build system conflicts**: Some distribution build systems (like
   Fedora's RPM packaging) have policies against running code quality
   tools during package builds, preferring to focus purely on functional
   testing.

This change:
- Removes coverage options from default pytest addopts
- Moves pytest-cov to the 'lint' dependency group (alongside other code
  quality tools like ruff and mypy)
- Updates GitHub Actions workflow to explicitly enable coverage with
  flags when needed for CI

Benefits:
- Developers can still collect coverage by passing `--cov=eip712` flags
- CI/CD workflows remain unchanged (coverage still collected)
- Easier for downstream packagers to run functional tests without
  installing/running quality tools
- Clearer separation: test dependencies vs. development/quality
  dependencies

This aligns with the principle that coverage is a quality metric for
development, not a functional requirement for test execution.

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Assisted-by: Claude (Anthropic) <https://claude.ai>
@lemenkov
lemenkov force-pushed the separate_cov_and_lint branch from 31ff80f to ecfbf46 Compare December 13, 2025 13:16
@lemenkov lemenkov changed the title refactor: move pytest-cov from default test options to optional lint group refactor: move pytest-cov to lint dependency group Dec 13, 2025
@fubuloubu

Copy link
Copy Markdown
Member

You can run it without coverage via pytest --no-cov

Not sure I share your concern, at the very least I wouldn't put it under linting tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants