"""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