diff --git a/test/general/TestLocations.py b/test/general/TestLocations.py index 5dbb1d55..f1b3349e 100644 --- a/test/general/TestLocations.py +++ b/test/general/TestLocations.py @@ -1,6 +1,6 @@ import unittest from collections import Counter -from worlds.AutoWorld import AutoWorldRegister +from worlds.AutoWorld import AutoWorldRegister, call_all from . import setup_solo_multiworld @@ -23,3 +23,33 @@ class TestBase(unittest.TestCase): for location in locations: self.assertIn(location.name, world_type.location_name_to_id) self.assertEqual(location.address, world_type.location_name_to_id[location.name]) + + def testLocationCreationSteps(self): + """Tests that Regions and Locations aren't created after `create_items`.""" + gen_steps = ("generate_early", "create_regions", "create_items") + for game_name, world_type in AutoWorldRegister.world_types.items(): + with self.subTest("Game", game_name=game_name): + multiworld = setup_solo_multiworld(world_type, gen_steps) + multiworld._recache() + region_count = len(multiworld.get_regions()) + location_count = len(multiworld.get_locations()) + + call_all(multiworld, "set_rules") + self.assertEqual(region_count, len(multiworld.get_regions()), + f"{game_name} modified region count during rule creation") + self.assertEqual(location_count, len(multiworld.get_locations()), + f"{game_name} modified locations count during rule creation") + + multiworld._recache() + call_all(multiworld, "generate_basic") + self.assertEqual(region_count, len(multiworld.get_regions()), + f"{game_name} modified region count during generate_basic") + self.assertGreaterEqual(location_count, len(multiworld.get_locations()), + f"{game_name} modified locations count during generate_basic") + + multiworld._recache() + call_all(multiworld, "pre_fill") + self.assertEqual(region_count, len(multiworld.get_regions()), + f"{game_name} modified region count during pre_fill") + self.assertGreaterEqual(location_count, len(multiworld.get_locations()), + f"{game_name} modified locations count during pre_fill") diff --git a/test/general/__init__.py b/test/general/__init__.py index 970c4ef9..b0fb7ca3 100644 --- a/test/general/__init__.py +++ b/test/general/__init__.py @@ -1,12 +1,13 @@ from argparse import Namespace +from typing import Type, Tuple from BaseClasses import MultiWorld -from worlds.AutoWorld import call_all +from worlds.AutoWorld import call_all, World -gen_steps = ["generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill"] +gen_steps = ("generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill") -def setup_solo_multiworld(world_type) -> MultiWorld: +def setup_solo_multiworld(world_type: Type[World], steps: Tuple[str, ...] = gen_steps) -> MultiWorld: multiworld = MultiWorld(1) multiworld.game[1] = world_type.game multiworld.player_name = {1: "Tester"} @@ -16,6 +17,6 @@ def setup_solo_multiworld(world_type) -> MultiWorld: setattr(args, name, {1: option.from_any(option.default)}) multiworld.set_options(args) multiworld.set_default_common_options() - for step in gen_steps: + for step in steps: call_all(multiworld, step) return multiworld