diff --git a/test/general/test_items.py b/test/general/test_items.py index 2d8775d5..bd6c3fd8 100644 --- a/test/general/test_items.py +++ b/test/general/test_items.py @@ -1,5 +1,6 @@ import unittest -from worlds.AutoWorld import AutoWorldRegister + +from worlds.AutoWorld import AutoWorldRegister, call_all from . import setup_solo_multiworld @@ -53,7 +54,7 @@ class TestBase(unittest.TestCase): f"{game_name} Item count MUST meet or exceed the number of locations", ) - def testItemsInDatapackage(self): + def test_items_in_datapackage(self): """Test that any created items in the itempool are in the datapackage""" for game_name, world_type in AutoWorldRegister.world_types.items(): with self.subTest("Game", game=game_name): @@ -69,3 +70,20 @@ class TestBase(unittest.TestCase): with self.subTest("Name should be valid", game=game_name, item=name): self.assertIn(name, valid_names, "All item descriptions must match defined item names") + + def test_itempool_not_modified(self): + """Test that worlds don't modify the itempool after `create_items`""" + gen_steps = ("generate_early", "create_regions", "create_items") + additional_steps = ("set_rules", "generate_basic", "pre_fill") + excluded_games = ("Links Awakening DX", "Ocarina of Time", "SMZ3") + worlds_to_test = {game: world + for game, world in AutoWorldRegister.world_types.items() if game not in excluded_games} + for game_name, world_type in worlds_to_test.items(): + with self.subTest("Game", game=game_name): + multiworld = setup_solo_multiworld(world_type, gen_steps) + created_items = multiworld.itempool.copy() + for step in additional_steps: + with self.subTest("step", step=step): + call_all(multiworld, step) + self.assertEqual(created_items, multiworld.itempool, + f"{game_name} modified the itempool during {step}") diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index f56c39f6..d4e463db 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -328,7 +328,7 @@ class World(metaclass=AutoWorldRegister): def create_items(self) -> None: """ - Method for creating and submitting items to the itempool. Items and Regions should *not* be created and submitted + Method for creating and submitting items to the itempool. Items and Regions must *not* be created and submitted to the MultiWorld after this step. If items need to be placed during pre_fill use `get_prefill_items`. """ pass