| 
									
										
										
										
											2025-04-11 20:41:08 -04:00
										 |  |  | import os | 
					
						
							|  |  |  | from argparse import Namespace | 
					
						
							| 
									
										
										
										
											2023-10-18 15:53:12 -04:00
										 |  |  | from typing import ClassVar | 
					
						
							|  |  |  | from typing import Dict, FrozenSet, Tuple, Any | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from BaseClasses import MultiWorld | 
					
						
							| 
									
										
										
										
											2024-11-06 03:36:49 -05:00
										 |  |  | from test.bases import WorldTestBase | 
					
						
							| 
									
										
										
										
											2023-10-18 15:53:12 -04:00
										 |  |  | from test.general import gen_steps, setup_solo_multiworld as setup_base_solo_multiworld | 
					
						
							|  |  |  | from worlds.AutoWorld import call_all | 
					
						
							| 
									
										
										
										
											2025-04-11 20:41:08 -04:00
										 |  |  | from .. import DLCqworld | 
					
						
							| 
									
										
										
										
											2023-10-18 15:53:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DLCQuestTestBase(WorldTestBase): | 
					
						
							|  |  |  |     game = "DLCQuest" | 
					
						
							|  |  |  |     world: DLCqworld | 
					
						
							|  |  |  |     player: ClassVar[int] = 1 | 
					
						
							| 
									
										
										
										
											2025-04-11 20:41:08 -04:00
										 |  |  |     # Set False to run tests that take long | 
					
						
							|  |  |  |     skip_long_tests: bool = True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @classmethod | 
					
						
							|  |  |  |     def setUpClass(cls) -> None: | 
					
						
							|  |  |  |         super().setUpClass() | 
					
						
							|  |  |  |         cls.skip_long_tests = not bool(os.environ.get("long")) | 
					
						
							| 
									
										
										
										
											2023-10-18 15:53:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def world_setup(self, *args, **kwargs): | 
					
						
							|  |  |  |         super().world_setup(*args, **kwargs) | 
					
						
							|  |  |  |         if self.constructed: | 
					
						
							|  |  |  |             self.world = self.multiworld.worlds[self.player]  # noqa | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @property | 
					
						
							|  |  |  |     def run_default_tests(self) -> bool: | 
					
						
							|  |  |  |         # world_setup is overridden, so it'd always run default tests when importing DLCQuestTestBase | 
					
						
							|  |  |  |         is_not_dlc_test = type(self) is not DLCQuestTestBase | 
					
						
							|  |  |  |         should_run_default_tests = is_not_dlc_test and super().run_default_tests | 
					
						
							|  |  |  |         return should_run_default_tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def setup_dlc_quest_solo_multiworld(test_options=None, seed=None, _cache: Dict[FrozenSet[Tuple[str, Any]], MultiWorld] = {}) -> MultiWorld: #noqa | 
					
						
							|  |  |  |     if test_options is None: | 
					
						
							|  |  |  |         test_options = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Yes I reuse the worlds generated between tests, its speeds the execution by a couple seconds | 
					
						
							|  |  |  |     frozen_options = frozenset(test_options.items()).union({seed}) | 
					
						
							|  |  |  |     if frozen_options in _cache: | 
					
						
							|  |  |  |         return _cache[frozen_options] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-10 12:47:45 -05:00
										 |  |  |     multiworld = setup_base_solo_multiworld(DLCqworld, (), seed=seed) | 
					
						
							| 
									
										
										
										
											2023-10-18 15:53:12 -04:00
										 |  |  |     # print(f"Seed: {multiworld.seed}") # Uncomment to print the seed for every test | 
					
						
							|  |  |  |     args = Namespace() | 
					
						
							|  |  |  |     for name, option in DLCqworld.options_dataclass.type_hints.items(): | 
					
						
							|  |  |  |         value = option(test_options[name]) if name in test_options else option.from_any(option.default) | 
					
						
							|  |  |  |         setattr(args, name, {1: value}) | 
					
						
							|  |  |  |     multiworld.set_options(args) | 
					
						
							|  |  |  |     for step in gen_steps: | 
					
						
							|  |  |  |         call_all(multiworld, step) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     _cache[frozen_options] = multiworld | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return multiworld |