Skip to content

Add comprehensive unit tests and modernize CI to uv + Python 3.11–3.13#3

Merged
MrLYC merged 7 commits intomainfrom
devin/1769543431-add-unit-tests
Feb 7, 2026
Merged

Add comprehensive unit tests and modernize CI to uv + Python 3.11–3.13#3
MrLYC merged 7 commits intomainfrom
devin/1769543431-add-unit-tests

Conversation

@MrLYC
Copy link
Owner

@MrLYC MrLYC commented Jan 27, 2026

Add comprehensive unit tests and modernize CI to uv + Python 3.11–3.13

Summary

This PR adds unit tests for all modules in the versifier project, increasing code coverage from 25% to 98%. The tests cover:

  • Config module: Configuration loading from pyproject.toml with both [tool.versifier] and [versifier] sections
  • Poetry module: RequirementsFile filtering/dumping and Poetry class methods (add_packages, install, export_requirements, etc.)
  • Compiler module: Nuitka3, Cython, and SmartCompiler classes including fallback behavior
  • Core module: DependencyManager, DependencyExporter, PackageExtractor, and PackageObfuscator
  • Main module: Context class properties and all CLI commands via Click's CliRunner
  • Stub module: Extended existing tests and added PackageStubGenerator tests

Tests use mocking extensively to avoid actual subprocess calls to external tools (poetry, nuitka, cython).

CI Workflow Modernization

  • Switched package manager from Poetry to uv (astral-sh/setup-uv@v7)
  • Updated runner from ubuntu-20.04 (deprecated) → ubuntu-latest
  • Updated Python matrix from ['3.6.15', '3.8.18', '3.11.9']['3.11', '3.12', '3.13']
  • Updated Makefile to use uv sync, uv run, and uv build in place of Poetry equivalents
  • Added PEP 621 [project] table to pyproject.toml (required by uv), while preserving [tool.poetry] section for backward compatibility (versifier internally calls poetry export)
  • Added setuptools and typing_extensions as dependencies (setuptools needed for Python 3.12+ which removed distutils)
  • Poetry is still installed in CI via uv tool install poetry + poetry-plugin-export because versifier extract-private-packages calls poetry export internally
  • poetry lock runs in CI to keep the lock file in sync with the updated pyproject.toml for Poetry 2.x

Review & Testing Checklist for Human

  • Dual config risk: pyproject.toml now has both [project] (PEP 621) and [tool.poetry] sections — verify these stay consistent and don't cause unexpected behavior with either uv or Poetry
  • poetry lock in CI: The lock file is regenerated in CI on every run, meaning the committed poetry.lock may not match what CI actually uses — consider whether this masks dependency resolution issues
  • setuptools as runtime dependency: Added to work around distutils removal in Python 3.12+ (versifier/compiler.py imports from distutils.core import setup) — consider whether refactoring the import is preferable to adding a runtime dependency
  • Python version declaration: pyproject.toml declares requires-python = ">=3.11" — verify this is intentional and aligns with project goals (drops support for Python 3.6–3.10)
  • Run uv sync && uv run pytest locally on Python 3.11, 3.12, and 3.13 to verify the full test suite passes

Recommended Test Plan

  1. Clone the branch and run uv sync to install dependencies
  2. Run uv run pytest — expect 117 tests to pass
  3. Run make test check to verify the full CI command works locally
  4. Optionally test with each Python version (3.11, 3.12, 3.13) to ensure compatibility

Notes

  • All 3 CI jobs (Python 3.11, 3.12, 3.13) now pass
  • Tests pass with 117 tests and 98% coverage
  • Some tests access private methods (prefixed with _) which is acceptable for unit testing but worth noting
  • The versifier tool has a hard dependency on Poetry CLI for extract-private-packages command — this is why Poetry is installed alongside uv in CI

Link to Devin run: https://app.devin.ai/sessions/2b89e39464164fe085c3208ff2b164d7
Requested by: 刘奕聪 (@MrLYC)

devin-ai-integration bot and others added 2 commits January 27, 2026 19:56
- Add tests for versifier/config.py (Config class)
- Add tests for versifier/poetry.py (RequirementsFile and Poetry classes)
- Add tests for versifier/compiler.py (Nuitka3, Cython, SmartCompiler classes)
- Add tests for versifier/core.py (DependencyManager, DependencyExporter, PackageExtractor, PackageObfuscator)
- Add tests for versifier/__main__.py (Context class and CLI commands)
- Add tests for versifier/stub.py (PackageStubGenerator class)

Coverage increased from 25% to 98%

Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
… Poetry version

Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
@devin-ai-integration devin-ai-integration bot changed the title Add comprehensive unit tests to achieve 98% coverage Add comprehensive unit tests and fix CI workflow Feb 7, 2026
devin-ai-integration bot and others added 5 commits February 7, 2026 15:54
…test

Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
Co-Authored-By: 刘奕聪 <github@m.mrlyc.com>
@devin-ai-integration devin-ai-integration bot changed the title Add comprehensive unit tests and fix CI workflow Add comprehensive unit tests and modernize CI to uv + Python 3.11–3.13 Feb 7, 2026
@MrLYC MrLYC merged commit 04d2f44 into main Feb 7, 2026
3 checks passed
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.

1 participant