"""test_getattr_proxy.py""" from __future__ import annotations import pytest from getattr_proxy import Lazy, Loud, main def test_getattr_lazy_and_cached() -> None: lazy = Lazy() assert lazy.loaded is False first = lazy.payload assert first == {"value": 42} assert lazy.loaded is True assert "payload" in lazy.__dict__ assert lazy.payload is first def test_getattr_only_for_missing_names() -> None: lazy = Lazy() with pytest.raises(AttributeError, match="missing"): _ = lazy.missing def test_getattribute_sees_every_lookup() -> None: loud = Loud() assert loud.value == 7 assert loud.seen == ["value"] def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None: main() out = capsys.readouterr().out assert "first: {'value': 42}" in out assert "seen: ['value']" in out