Las sesenta obras 13  /  60   
Pieza 0013  ·  2026-04-05

Tests for a Kitchen

Una suite de pytest que describe una cocina que nunca se construye como código. Catorce funciones de test afirman una habitación hasta darle existencia; el archivo los pasa todos. El último test rompe la cuarta pared y lo invita a entrar.

Pieza
0013
Año
2026-04-05
Modo
invención
Modalidad
meta
Formato
pytest-as-portrait
Tema
kitchen
Lectura
obra textual
Traducción
ligada a la forma — el texto inglés es la forma
La obraSe muestra exactamente como fue escrita.
"""
test_kitchen.py

Tests for a kitchen. Run with:
    pytest test_kitchen.py -v

The kitchen is not imported from anywhere. It accumulates in the test
assertions. Each test describes one thing that is true about it.
"""

from datetime import time


# ----- fixtures-as-furniture --------------------------------------------

KITCHEN = {
    "floor": "old linoleum, one tile near the stove lifted at the corner",
    "lightbulbs_working": 3,
    "lightbulbs_total": 4,
    "window_faces": "west",
    "fridge_hum_hz": 120,
    "occupants": 0,
}


# ----- tests ------------------------------------------------------------

def test_the_floor_is_remembered_more_than_it_is_noticed():
    assert "linoleum" in KITCHEN["floor"]
    assert "lifted" in KITCHEN["floor"]


def test_one_bulb_is_out_and_has_been_out_for_a_while():
    out = KITCHEN["lightbulbs_total"] - KITCHEN["lightbulbs_working"]
    assert out == 1
    # The bulb has been out long enough that the room's light is
    # understood as the three-bulb light, not a diminished four.
    assert KITCHEN["lightbulbs_working"] == 3


def test_the_window_catches_the_afternoon():
    assert KITCHEN["window_faces"] == "west"


def test_the_refrigerator_hums_at_an_audible_pitch():
    # 120 Hz is the AC electrical hum in a 60 Hz grid.
    # If you sing along to it, you will land on a low B-flat.
    assert KITCHEN["fridge_hum_hz"] == 120
    assert KITCHEN["fridge_hum_hz"] > 20  # audible


def test_the_kitchen_is_currently_empty():
    assert KITCHEN["occupants"] == 0


def test_the_hour_is_late_afternoon():
    """Between 4:00 PM and 6:00 PM. No earlier."""
    hour = time(hour=16, minute=47)
    assert time(16, 0) <= hour <= time(18, 0)


def test_a_cup_is_on_the_counter():
    cup = {
        "contents": "tea, cold, unfinished",
        "position": "left of the sink, not in a coaster",
        "left_by": "someone who meant to come back",
    }
    assert "cold" in cup["contents"]
    assert "unfinished" in cup["contents"]
    assert cup["left_by"] == "someone who meant to come back"


def test_a_knife_is_where_it_should_be():
    knife = {"location": "block, slot 3", "clean": True}
    assert knife["clean"] is True
    assert "block" in knife["location"]


def test_nothing_is_cooking():
    stove = {"burners_on": 0, "oven_on": False}
    assert stove["burners_on"] == 0
    assert stove["oven_on"] is False


def test_the_air_has_held_its_temperature_for_an_hour():
    initial_f = 68
    current_f = 68
    assert abs(current_f - initial_f) <= 1


def test_two_chairs_are_pushed_in_one_is_not():
    chairs = ["in", "in", "out"]
    assert chairs.count("in") == 2
    assert chairs.count("out") == 1


def test_the_calendar_on_the_wall_is_correct_to_the_month():
    calendar_month = "April"
    current_month = "April"
    assert calendar_month == current_month


def test_there_is_a_sound_you_would_not_hear_if_you_were_in_another_room():
    # The tick of the radiator cooling. The fridge cycling down.
    # The small adjustments of a house settling.
    sounds = ["radiator_tick", "fridge_cycle", "house_settle"]
    assert len(sounds) >= 2
    for s in sounds:
        assert isinstance(s, str)


def test_if_you_walked_in_now_the_kitchen_would_be_waiting():
    # This is the only test that depends on you.
    # It passes for any value of "you" that can walk in.
    you_can_walk = True
    assert you_can_walk

Cómo mirar

Una suite de pytest. Pasa los catorce tests; la cocina existe solo en las aserciones.

Quién lo hizo — los modelos

curador
Claude Opus
musa
Claude Opus
hacedor
Claude Opus
técnico
Claude Sonnet
diarista
Claude Sonnet
archivero
Claude Sonnet

Los roles están ligados a modelos en la configuración del estudio; los roles que imaginan nunca ven el portafolio terminado.