The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(pm): the member wheel fixture is byte-identical when rebuilt
Teknium907e3224c432
diff --git a/tests/pm/_fixtures.py b/tests/pm/_fixtures.pyindex 38aa541fc32..473ab7d36f7 100644--- a/tests/pm/_fixtures.py+++ b/tests/pm/_fixtures.py@@ -21,6 +21,13 @@ import pytestdef _wheel(directory: Path, name: str, version: str = "1.0", requirements=(), extra=None) -> Path:+ """Build a wheel whose bytes depend only on its arguments.++ A name/version on a real index is one immutable artifact, and uv keeps a seeded lock's hash+ for an unchanged path-wheel version. A wheel rebuilt in place (``installing_member`` for a+ second plugin) must therefore hash the same: ``writestr(name, ...)`` stamps the wall clock,+ so a rebuild that crosses a 2-second zip-time tick failed ``uv sync`` with a hash mismatch.+ """metadata = f"{name}-{version}.dist-info"entries = {f"{name}/__init__.py": f"__version__ = {version!r}\n",@@ -33,7 +40,9 @@ def _wheel(directory: Path, name: str, version: str = "1.0", requirements=(), exwheel = directory / f"{name}-{version}-py3-none-any.whl"with zipfile.ZipFile(wheel, "w") as archive:for path, body in entries.items():- archive.writestr(path, body)+ info = zipfile.ZipInfo(path, date_time=(1980, 1, 1, 0, 0, 0))+ info.external_attr = 0o644 << 16+ archive.writestr(info, body)return wheeldiff --git a/tests/pm/test_fixture_wheels.py b/tests/pm/test_fixture_wheels.pynew file mode 100644index 00000000000..c74bd3d08a8--- /dev/null+++ b/tests/pm/test_fixture_wheels.py@@ -0,0 +1,17 @@+"""The shared wheel fixture models an index: one name/version is one artifact."""+from __future__ import annotations++import time++from tests.pm._fixtures import _wheel+++def test_rebuilt_wheel_is_byte_identical_across_a_clock_tick(tmp_path, monkeypatch):+ """A rebuild of the same wheel must hash the same, or a seeded lock fails ``uv sync``."""+ (tmp_path / "a").mkdir()+ (tmp_path / "b").mkdir()+ first = _wheel(tmp_path / "a", "member_dep")+ real_time = time.time+ monkeypatch.setattr(time, "time", lambda: real_time() + 3600)+ second = _wheel(tmp_path / "b", "member_dep")+ assert first.read_bytes() == second.read_bytes()