diff --git a/test/Reachability.py b/test/Reachability.py deleted file mode 100644 index 73310ab7b4..0000000000 --- a/test/Reachability.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest -from argparse import Namespace -from BaseClasses import MultiWorld -from worlds.AutoWorld import AutoWorldRegister, call_all - - -class TestBase(unittest.TestCase): - _state_cache = {} - gen_steps = ["generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill"] - - def testAllStateCanReachEverything(self): - for game_name, world_type in AutoWorldRegister.world_types.items(): - if game_name != "Ori and the Blind Forest": # TODO: fix Ori Logic - with self.subTest("Game", game=game_name): - - world = MultiWorld(1) - world.game[1] = game_name - world.player_name = {1: "Tester"} - world.set_seed() - args = Namespace() - for name, option in world_type.options.items(): - setattr(args, name, {1: option.from_any(option.default)}) - world.set_options(args) - world.set_default_common_options() - for step in self.gen_steps: - call_all(world, step) - state = world.get_all_state(False) - for location in world.get_locations(): - with self.subTest("Location should be reached", location=location): - self.assertTrue(location.can_reach(state)) diff --git a/test/general/TestReachability.py b/test/general/TestReachability.py new file mode 100644 index 0000000000..b730d7be3f --- /dev/null +++ b/test/general/TestReachability.py @@ -0,0 +1,33 @@ +import unittest + +from BaseClasses import CollectionState +from worlds.AutoWorld import AutoWorldRegister + +from . import setup_default_world + +class TestBase(unittest.TestCase): + _state_cache = {} + gen_steps = ["generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill"] + + def testAllStateCanReachEverything(self): + for game_name, world_type in AutoWorldRegister.world_types.items(): + if game_name != "Ori and the Blind Forest": # TODO: fix Ori Logic + with self.subTest("Game", game=game_name): + world = setup_default_world(world_type) + state = world.get_all_state(False) + for location in world.get_locations(): + with self.subTest("Location should be reached", location=location): + self.assertTrue(location.can_reach(state)) + + def testEmptyStateCanReachSomething(self): + for game_name, world_type in AutoWorldRegister.world_types.items(): + if game_name != "Archipelago": + with self.subTest("Game", game=game_name): + world = setup_default_world(world_type) + state = CollectionState(world) + locations = set() + for location in world.get_locations(): + if location.can_reach(state): + locations.add(location) + self.assertGreater(len(locations), 0, + msg="Need to be able to reach at least one location to get started.") \ No newline at end of file diff --git a/test/general/__init__.py b/test/general/__init__.py new file mode 100644 index 0000000000..b95399f83f --- /dev/null +++ b/test/general/__init__.py @@ -0,0 +1,21 @@ +from argparse import Namespace + +from BaseClasses import MultiWorld +from worlds.AutoWorld import call_all + +gen_steps = ["generate_early", "create_regions", "create_items", "set_rules", "generate_basic", "pre_fill"] + + +def setup_default_world(world_type): + world = MultiWorld(1) + world.game[1] = world_type.game + world.player_name = {1: "Tester"} + world.set_seed() + args = Namespace() + for name, option in world_type.options.items(): + setattr(args, name, {1: option.from_any(option.default)}) + world.set_options(args) + world.set_default_common_options() + for step in gen_steps: + call_all(world, step) + return world \ No newline at end of file