- version 2026.08.17 in pyproject and __init__, kept in sync by a test - add the MIT LICENSE file the metadata already claimed; it ships in both the sdist and the wheel - classifiers and Repository URL following the convention used by the other MCP servers (git.supported.systems/MCP/<name>) - tests/test_packaging.py guards the invariants that only bite after upload: version drift, an unimportable console-script target, a declared license with no file, and a Python floor that moves ahead of what we test
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Packaging invariants — cheap guards against publishing something wrong.
|
|
|
|
PyPI is immutable per version, so these are worth catching before upload
|
|
rather than after.
|
|
"""
|
|
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
import mcqemu
|
|
|
|
PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
|
|
|
|
|
def project_metadata() -> dict:
|
|
return tomllib.loads(PYPROJECT.read_text())["project"]
|
|
|
|
|
|
def test_version_matches_pyproject():
|
|
"""__version__ is what the startup banner prints; drift is confusing."""
|
|
assert mcqemu.__version__ == project_metadata()["version"]
|
|
|
|
|
|
def test_console_script_target_is_importable():
|
|
"""A typo here only shows up after install, when `mcqemu` fails to start."""
|
|
module, _, attr = project_metadata()["scripts"]["mcqemu"].partition(":")
|
|
imported = __import__(module, fromlist=[attr])
|
|
assert callable(getattr(imported, attr))
|
|
|
|
|
|
def test_license_file_ships_with_the_declared_license():
|
|
metadata = project_metadata()
|
|
assert metadata["license"] == "MIT"
|
|
license_text = (PYPROJECT.parent / "LICENSE").read_text()
|
|
assert "MIT License" in license_text
|
|
assert "Ryan Malloy" in license_text
|
|
|
|
|
|
def test_declared_python_floor_is_honest():
|
|
"""We test against this floor; it must not silently move ahead of us."""
|
|
assert project_metadata()["requires-python"] == ">=3.11"
|
|
classifiers = project_metadata()["classifiers"]
|
|
assert "Programming Language :: Python :: 3.11" in classifiers
|