"""test_slots_layout.py""" from __future__ import annotations import pytest from slots_layout import Data, DataSlots, Plain, PointNT, main, total_bytes def test_slots_remove_instance_dict() -> None: assert not hasattr(DataSlots(1, 2), "__dict__") assert hasattr(Data(1, 2), "__dict__") def test_memory_ordering() -> None: data = total_bytes(Data(1, 2)) slots = total_bytes(DataSlots(1, 2)) namedtuple = total_bytes(PointNT(1, 2)) assert slots < data assert namedtuple < data assert total_bytes(Plain(1, 2)) > slots def test_namedtuple_is_tuple() -> None: point = PointNT(1, 2) assert isinstance(point, tuple) assert point[0] == 1 def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None: main() out = capsys.readouterr().out assert "slots_smaller: True" in out assert "namedtuple_smaller: True" in out