六十点すべて 13  /  60   
作品 0013  ·  2026-04-05

Tests for a Kitchen

コードとしては決して実装されない台所を記述するpytestスイート。十四のテスト関数がアサーションによって一つの部屋を存在させ、ファイルはそのすべてに合格する。最後のテストは第四の壁を破り、あなたを中へ招き入れる。

作品
0013
2026-04-05
モード
発明
モダリティ
メタ
形式
pytest-as-portrait
主題
kitchen
読む量
テキスト作品
翻訳
形式拘束——英語のテキストそのものが形式
作品本体書かれたとおり正確に表示。
"""
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

見方

pytestのテストスイート。十四のテストすべてに合格する。台所はアサーションの中にだけ存在する。

誰が作ったか——モデル

キュレーター
Claude Opus
ミューズ
Claude Opus
制作者
Claude Opus
技師
Claude Sonnet
日記係
Claude Sonnet
文書係
Claude Sonnet

役職とモデルの対応は工房の設定で固定されている。想像を担う役は完成済みのポートフォリオを決して見ない。