diff --git a/test/hosting/__main__.py b/test/hosting/__main__.py index 8f2a34a7a8..7ac2700eb8 100644 --- a/test/hosting/__main__.py +++ b/test/hosting/__main__.py @@ -70,13 +70,13 @@ if __name__ == "__main__": empty_file = str(Path(tempdir) / "empty") open(empty_file, "w").close() sys.argv += ["--config_override", empty_file] # tests #5541 - multis = [["VVVVVV"], ["Temp World"], ["VVVVVV", "Temp World"]] + multis = [["APQuest"], ["Temp World"], ["APQuest", "Temp World"]] p1_games: list[str] = [] data_paths: list[Path | None] = [] rooms: list[str] = [] multidata: Path | None - copy_world("VVVVVV", "Temp World") + copy_world("APQuest", "Temp World") try: for n, games in enumerate(multis, 1): print(f"Generating [{n}] {', '.join(games)} offline") diff --git a/test/hosting/world.py b/test/hosting/world.py index 20f8df8cb1..9a523f6845 100644 --- a/test/hosting/world.py +++ b/test/hosting/world.py @@ -20,7 +20,7 @@ def copy(src: str, dst: str) -> None: src_cls = AutoWorldRegister.world_types[src] src_folder = Path(src_cls.__file__).parent worlds_folder = src_folder.parent - if (not src_cls.__file__.endswith("__init__.py") or not src_folder.is_dir() + if (not src_cls.__file__.endswith(("__init__.py", "world.py")) or not src_folder.is_dir() or not (worlds_folder / "generic").is_dir()): raise ValueError(f"Unsupported layout for copy_world from {src}") dst_folder = worlds_folder / dst_folder_name @@ -28,11 +28,14 @@ def copy(src: str, dst: str) -> None: raise ValueError(f"Destination {dst_folder} already exists") shutil.copytree(src_folder, dst_folder) _new_worlds[dst] = str(dst_folder) - with open(dst_folder / "__init__.py", "r", encoding="utf-8-sig") as f: - contents = f.read() - contents = re.sub(r'game\s*(:\s*[a-zA-Z\[\]]+)?\s*=\s*[\'"]' + re.escape(src) + r'[\'"]', f'game = "{dst}"', contents) - with open(dst_folder / "__init__.py", "w", encoding="utf-8") as f: - f.write(contents) + + for potential_world_class_file in ("__init__.py", "world.py"): + with open(dst_folder / potential_world_class_file, "r", encoding="utf-8-sig") as f: + contents = f.read() + r_src = re.escape(src) + contents = re.sub(r'game\s*(:\s*[a-zA-Z\[\]]+)?\s*=\s*[\'"]' + r_src + r'[\'"]', f'game = "{dst}"', contents) + with open(dst_folder / "__init__.py", "w", encoding="utf-8") as f: + f.write(contents) def delete(name: str) -> None: