From a37968cc0d41535a203bf2ec2b5c3b3a9f311fd1 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Mon, 16 Nov 2026 01:59:50 -0700 Subject: [PATCH] test: pin a save in an unknown place, an uncopyable damaged save and closing the log unread Three paths no test reached: a save whose location the game no longer has resumes in the galley with its facts kept; a damaged save that cannot be copied aside says so and leaves no backup behind; and opening the station log and closing it unread costs no watch and teaches nothing. Co-Authored-By: Claude Opus 5.5 --- tests/test_game.py | 41 +++++++++++++++++++++++++++++++++++++++++ tests/test_scenes.py | 10 ++++++++++ 2 files changed, 51 insertions(+) diff --git a/tests/test_game.py b/tests/test_game.py index 7fb0d4e..7632d2a 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -228,6 +228,47 @@ def test_a_damaged_save_is_kept_aside_and_a_fresh_winter_starts(scripted, tmp_pa assert game2.state.day == 1 +def test_a_damaged_save_that_cannot_be_copied_aside_says_so(scripted, monkeypatch): + from overwinter import game as gameModule + + game, ui = scripted(["Create New Save", "Quit"]) + game.play() + path = game.saveFileManager.get_save_path("save.json") + with open(path, "w") as f: + f.write('{"version": 1, "day": "seven"}') + + def refuse(source, destination): + raise OSError("read-only") + + monkeypatch.setattr(gameModule.shutil, "copy2", refuse) + game2, ui2 = scripted(["Load Slot 1", "Quit"]) + game2.play() + assert ui2.saw("This save could not be read") + assert ui2.saw("It could not be copied aside.") + assert not ui2.saw("A copy was kept at") + assert not [n for n in os.listdir(os.path.dirname(path)) if "damaged" in n] + assert game2.state.day == 1 + + +def test_a_save_in_a_place_the_game_no_longer_has_resumes_in_the_galley(scripted): + game, ui = scripted(["Create New Save", "Count the store", "Quit"]) + game.play() + path = game.saveFileManager.get_save_path("save.json") + with open(path) as f: + data = json.load(f) + data["location"] = "the_old_radio_mast" + with open(path, "w") as f: + json.dump(data, f) + + game2, ui2 = scripted(["Load Slot 1", "Quit"]) + game2.play() + assert not game2.failedLoad + assert game2.state.location == "galley" + assert game2.state.knows(facts.THE_STORE) + # The first menu after the slot menu is the galley's. + assert "Count the store" in ui2.menus[1][1] + + def test_letting_aksel_go_is_an_ending_of_its_own(scripted): script = list(FULL_RUN) script[script.index("He's coming with us")] = "Let him go" diff --git a/tests/test_scenes.py b/tests/test_scenes.py index c6c546d..c1f0090 100644 --- a/tests/test_scenes.py +++ b/tests/test_scenes.py @@ -14,6 +14,7 @@ Galley, ) from overwinter.scenes.hut import Hut +from overwinter.scenes.office import Office from overwinter.scenes.shed import Shed from overwinter.state import ( AKSEL_HUT, @@ -203,6 +204,15 @@ def test_the_hut_after_aksel_has_come_in_is_cold_and_has_nobody_to_talk_to(): assert game.ui.saw("Nothing left in it that was not here in 1961.") +def test_opening_the_station_log_and_closing_it_unread_costs_nothing(): + game, office = scene(Office, ["Read the station log", "Close the log"], "office") + assert office.run() == "office" + assert "Close the log" in game.ui.menus[-1][1] + assert game.state.facts == [] + assert game.state.watch == MORNING + assert game.state.day == 1 + + def test_the_epilogue_rereads_the_last_page_and_opens_the_journal_for_free(): game, epilogue = scene( Epilogue,