Tests: modern PEP8-ify core test modules and methods (#2298)
* rename modules * rename methods * add docstrings to the general tests * add base import stub * test_base -> bases * print deprecation warning * redo 2346
This commit is contained in:
@@ -8,6 +8,13 @@ gen_steps = ("generate_early", "create_regions", "create_items", "set_rules", "g
|
||||
|
||||
|
||||
def setup_solo_multiworld(world_type: Type[World], steps: Tuple[str, ...] = gen_steps) -> MultiWorld:
|
||||
"""
|
||||
Creates a multiworld with a single player of `world_type`, sets default options, and calls provided gen steps.
|
||||
|
||||
:param world_type: Type of the world to generate a multiworld for
|
||||
:param steps: The gen steps that should be called on the generated multiworld before returning. Default calls
|
||||
steps through pre_fill
|
||||
"""
|
||||
multiworld = MultiWorld(1)
|
||||
multiworld.game[1] = world_type.game
|
||||
multiworld.player_name = {1: "Tester"}
|
||||
|
||||
@@ -72,7 +72,7 @@ class PlayerDefinition(object):
|
||||
return region
|
||||
|
||||
|
||||
def fillRegion(world: MultiWorld, region: Region, items: List[Item]) -> List[Item]:
|
||||
def fill_region(world: MultiWorld, region: Region, items: List[Item]) -> List[Item]:
|
||||
items = items.copy()
|
||||
while len(items) > 0:
|
||||
location = region.locations.pop(0)
|
||||
@@ -86,7 +86,7 @@ def fillRegion(world: MultiWorld, region: Region, items: List[Item]) -> List[Ite
|
||||
return items
|
||||
|
||||
|
||||
def regionContains(region: Region, item: Item) -> bool:
|
||||
def region_contains(region: Region, item: Item) -> bool:
|
||||
for location in region.locations:
|
||||
if location.item == item:
|
||||
return True
|
||||
@@ -133,6 +133,7 @@ def names(objs: list) -> Iterable[str]:
|
||||
|
||||
class TestFillRestrictive(unittest.TestCase):
|
||||
def test_basic_fill(self):
|
||||
"""Tests `fill_restrictive` fills and removes the locations and items from their respective lists"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
|
||||
@@ -150,6 +151,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual([], player1.prog_items)
|
||||
|
||||
def test_ordered_fill(self):
|
||||
"""Tests `fill_restrictive` fulfills set rules"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
items = player1.prog_items
|
||||
@@ -166,6 +168,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(locations[1].item, items[1])
|
||||
|
||||
def test_partial_fill(self):
|
||||
"""Tests that `fill_restrictive` returns unfilled locations"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 3, 2)
|
||||
|
||||
@@ -191,6 +194,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(player1.locations[0], loc2)
|
||||
|
||||
def test_minimal_fill(self):
|
||||
"""Test that fill for minimal player can have unreachable items"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
|
||||
@@ -246,6 +250,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
f'{item} is unreachable in {item.location}')
|
||||
|
||||
def test_reversed_fill(self):
|
||||
"""Test a different set of rules can be satisfied"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
|
||||
@@ -264,6 +269,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(loc1.item, item0)
|
||||
|
||||
def test_multi_step_fill(self):
|
||||
"""Test that fill is able to satisfy multiple spheres"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 4, 4)
|
||||
|
||||
@@ -288,6 +294,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(locations[3].item, items[3])
|
||||
|
||||
def test_impossible_fill(self):
|
||||
"""Test that fill raises an error when it can't place any items"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
items = player1.prog_items
|
||||
@@ -304,6 +311,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
player1.locations.copy(), player1.prog_items.copy())
|
||||
|
||||
def test_circular_fill(self):
|
||||
"""Test that fill raises an error when it can't place all items"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 3, 3)
|
||||
|
||||
@@ -324,6 +332,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
player1.locations.copy(), player1.prog_items.copy())
|
||||
|
||||
def test_competing_fill(self):
|
||||
"""Test that fill raises an error when it can't place items in a way to satisfy the conditions"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
|
||||
@@ -340,6 +349,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
player1.locations.copy(), player1.prog_items.copy())
|
||||
|
||||
def test_multiplayer_fill(self):
|
||||
"""Test that items can be placed across worlds"""
|
||||
multi_world = generate_multi_world(2)
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
player2 = generate_player_data(multi_world, 2, 2, 2)
|
||||
@@ -360,6 +370,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(player2.locations[1].item, player2.prog_items[0])
|
||||
|
||||
def test_multiplayer_rules_fill(self):
|
||||
"""Test that fill across worlds satisfies the rules"""
|
||||
multi_world = generate_multi_world(2)
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
player2 = generate_player_data(multi_world, 2, 2, 2)
|
||||
@@ -383,6 +394,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(player2.locations[1].item, player1.prog_items[1])
|
||||
|
||||
def test_restrictive_progress(self):
|
||||
"""Test that various spheres with different requirements can be filled"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, prog_item_count=25)
|
||||
items = player1.prog_items.copy()
|
||||
@@ -405,6 +417,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
locations, player1.prog_items)
|
||||
|
||||
def test_swap_to_earlier_location_with_item_rule(self):
|
||||
"""Test that item swap happens and works as intended"""
|
||||
# test for PR#1109
|
||||
multi_world = generate_multi_world(1)
|
||||
player1 = generate_player_data(multi_world, 1, 4, 4)
|
||||
@@ -430,6 +443,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(sphere1_loc.item, allowed_item, "Wrong item in Sphere 1")
|
||||
|
||||
def test_double_sweep(self):
|
||||
"""Test that sweep doesn't duplicate Event items when sweeping"""
|
||||
# test for PR1114
|
||||
multi_world = generate_multi_world(1)
|
||||
player1 = generate_player_data(multi_world, 1, 1, 1)
|
||||
@@ -445,6 +459,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
self.assertEqual(multi_world.state.prog_items[item.name, item.player], 1, "Sweep collected multiple times")
|
||||
|
||||
def test_correct_item_instance_removed_from_pool(self):
|
||||
"""Test that a placed item gets removed from the submitted pool"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(multi_world, 1, 2, 2)
|
||||
|
||||
@@ -461,6 +476,7 @@ class TestFillRestrictive(unittest.TestCase):
|
||||
|
||||
class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
def test_basic_distribute(self):
|
||||
"""Test that distribute_items_restrictive is deterministic"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -480,6 +496,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertFalse(locations[3].event)
|
||||
|
||||
def test_excluded_distribute(self):
|
||||
"""Test that distribute_items_restrictive doesn't put advancement items on excluded locations"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -494,6 +511,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertFalse(locations[2].item.advancement)
|
||||
|
||||
def test_non_excluded_item_distribute(self):
|
||||
"""Test that useful items aren't placed on excluded locations"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -508,6 +526,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertEqual(locations[1].item, basic_items[0])
|
||||
|
||||
def test_too_many_excluded_distribute(self):
|
||||
"""Test that fill fails if it can't place all progression items due to too many excluded locations"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -520,6 +539,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertRaises(FillError, distribute_items_restrictive, multi_world)
|
||||
|
||||
def test_non_excluded_item_must_distribute(self):
|
||||
"""Test that fill fails if it can't place useful items due to too many excluded locations"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -534,6 +554,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertRaises(FillError, distribute_items_restrictive, multi_world)
|
||||
|
||||
def test_priority_distribute(self):
|
||||
"""Test that priority locations receive advancement items"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -548,6 +569,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertTrue(locations[3].item.advancement)
|
||||
|
||||
def test_excess_priority_distribute(self):
|
||||
"""Test that if there's more priority locations than advancement items, they can still fill"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -562,6 +584,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertFalse(locations[3].item.advancement)
|
||||
|
||||
def test_multiple_world_priority_distribute(self):
|
||||
"""Test that priority fill can be satisfied for multiple worlds"""
|
||||
multi_world = generate_multi_world(3)
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -591,7 +614,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertTrue(player3.locations[3].item.advancement)
|
||||
|
||||
def test_can_remove_locations_in_fill_hook(self):
|
||||
|
||||
"""Test that distribute_items_restrictive calls the fill hook and allows for item and location removal"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -611,6 +634,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertIsNone(removed_location[0].item)
|
||||
|
||||
def test_seed_robust_to_item_order(self):
|
||||
"""Test deterministic fill"""
|
||||
mw1 = generate_multi_world()
|
||||
gen1 = generate_player_data(
|
||||
mw1, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -628,6 +652,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertEqual(gen1.locations[3].item, gen2.locations[3].item)
|
||||
|
||||
def test_seed_robust_to_location_order(self):
|
||||
"""Test deterministic fill even if locations in a region are reordered"""
|
||||
mw1 = generate_multi_world()
|
||||
gen1 = generate_player_data(
|
||||
mw1, 1, 4, prog_item_count=2, basic_item_count=2)
|
||||
@@ -646,6 +671,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertEqual(gen1.locations[3].item, gen2.locations[3].item)
|
||||
|
||||
def test_can_reserve_advancement_items_for_general_fill(self):
|
||||
"""Test that priority locations fill still satisfies item rules"""
|
||||
multi_world = generate_multi_world()
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, location_count=5, prog_item_count=5)
|
||||
@@ -655,14 +681,14 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
|
||||
location = player1.locations[0]
|
||||
location.progress_type = LocationProgressType.PRIORITY
|
||||
location.item_rule = lambda item: item != items[
|
||||
0] and item != items[1] and item != items[2] and item != items[3]
|
||||
location.item_rule = lambda item: item not in items[:4]
|
||||
|
||||
distribute_items_restrictive(multi_world)
|
||||
|
||||
self.assertEqual(location.item, items[4])
|
||||
|
||||
def test_non_excluded_local_items(self):
|
||||
"""Test that local items get placed locally in a multiworld"""
|
||||
multi_world = generate_multi_world(2)
|
||||
player1 = generate_player_data(
|
||||
multi_world, 1, location_count=5, basic_item_count=5)
|
||||
@@ -683,6 +709,7 @@ class TestDistributeItemsRestrictive(unittest.TestCase):
|
||||
self.assertFalse(item.location.event, False)
|
||||
|
||||
def test_early_items(self) -> None:
|
||||
"""Test that the early items API successfully places items early"""
|
||||
mw = generate_multi_world(2)
|
||||
player1 = generate_player_data(mw, 1, location_count=5, basic_item_count=5)
|
||||
player2 = generate_player_data(mw, 2, location_count=5, basic_item_count=5)
|
||||
@@ -762,21 +789,22 @@ class TestBalanceMultiworldProgression(unittest.TestCase):
|
||||
|
||||
# Sphere 1
|
||||
region = player1.generate_region(player1.menu, 20)
|
||||
items = fillRegion(multi_world, region, [
|
||||
items = fill_region(multi_world, region, [
|
||||
player1.prog_items[0]] + items)
|
||||
|
||||
# Sphere 2
|
||||
region = player1.generate_region(
|
||||
player1.regions[1], 20, lambda state: state.has(player1.prog_items[0].name, player1.id))
|
||||
items = fillRegion(
|
||||
items = fill_region(
|
||||
multi_world, region, [player1.prog_items[1], player2.prog_items[0]] + items)
|
||||
|
||||
# Sphere 3
|
||||
region = player2.generate_region(
|
||||
player2.menu, 20, lambda state: state.has(player2.prog_items[0].name, player2.id))
|
||||
fillRegion(multi_world, region, [player2.prog_items[1]] + items)
|
||||
fill_region(multi_world, region, [player2.prog_items[1]] + items)
|
||||
|
||||
def test_balances_progression(self) -> None:
|
||||
"""Tests that progression balancing moves progression items earlier"""
|
||||
self.multi_world.progression_balancing[self.player1.id].value = 50
|
||||
self.multi_world.progression_balancing[self.player2.id].value = 50
|
||||
|
||||
@@ -789,6 +817,7 @@ class TestBalanceMultiworldProgression(unittest.TestCase):
|
||||
self.player1.regions[1], self.player2.prog_items[0])
|
||||
|
||||
def test_balances_progression_light(self) -> None:
|
||||
"""Test that progression balancing still moves items earlier on minimum value"""
|
||||
self.multi_world.progression_balancing[self.player1.id].value = 1
|
||||
self.multi_world.progression_balancing[self.player2.id].value = 1
|
||||
|
||||
@@ -802,6 +831,7 @@ class TestBalanceMultiworldProgression(unittest.TestCase):
|
||||
self.player1.regions[1], self.player2.prog_items[0])
|
||||
|
||||
def test_balances_progression_heavy(self) -> None:
|
||||
"""Test that progression balancing moves items earlier on maximum value"""
|
||||
self.multi_world.progression_balancing[self.player1.id].value = 99
|
||||
self.multi_world.progression_balancing[self.player2.id].value = 99
|
||||
|
||||
@@ -815,6 +845,7 @@ class TestBalanceMultiworldProgression(unittest.TestCase):
|
||||
self.player1.regions[1], self.player2.prog_items[0])
|
||||
|
||||
def test_skips_balancing_progression(self) -> None:
|
||||
"""Test that progression balancing is skipped when players have it disabled"""
|
||||
self.multi_world.progression_balancing[self.player1.id].value = 0
|
||||
self.multi_world.progression_balancing[self.player2.id].value = 0
|
||||
|
||||
@@ -827,6 +858,7 @@ class TestBalanceMultiworldProgression(unittest.TestCase):
|
||||
self.player1.regions[2], self.player2.prog_items[0])
|
||||
|
||||
def test_ignores_priority_locations(self) -> None:
|
||||
"""Test that progression items on priority locations don't get moved by balancing"""
|
||||
self.multi_world.progression_balancing[self.player1.id].value = 50
|
||||
self.multi_world.progression_balancing[self.player2.id].value = 50
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
from argparse import Namespace
|
||||
from typing import Dict, Optional, Callable
|
||||
|
||||
from BaseClasses import MultiWorld, CollectionState, Region
|
||||
import unittest
|
||||
from typing import Callable, Dict, Optional
|
||||
|
||||
from BaseClasses import CollectionState, MultiWorld, Region
|
||||
|
||||
|
||||
class TestHelpers(unittest.TestCase):
|
||||
@@ -15,7 +14,8 @@ class TestHelpers(unittest.TestCase):
|
||||
self.multiworld.player_name = {1: "Tester"}
|
||||
self.multiworld.set_seed()
|
||||
|
||||
def testRegionHelpers(self) -> None:
|
||||
def test_region_helpers(self) -> None:
|
||||
"""Tests `Region.add_locations()` and `Region.add_exits()` have correct behavior"""
|
||||
regions: Dict[str, str] = {
|
||||
"TestRegion1": "I'm an apple",
|
||||
"TestRegion2": "I'm a banana",
|
||||
@@ -79,4 +79,5 @@ class TestHelpers(unittest.TestCase):
|
||||
current_region.add_exits(reg_exit_set[region])
|
||||
exit_names = {_exit.name for _exit in current_region.exits}
|
||||
for reg_exit in reg_exit_set[region]:
|
||||
self.assertTrue(f"{region} -> {reg_exit}" in exit_names, f"{region} -> {reg_exit} not in {exit_names}")
|
||||
self.assertTrue(f"{region} -> {reg_exit}" in exit_names,
|
||||
f"{region} -> {reg_exit} not in {exit_names}")
|
||||
@@ -15,6 +15,7 @@ class TestIDs(unittest.TestCase):
|
||||
cls.yaml_options = Utils.parse_yaml(f.read())
|
||||
|
||||
def test_utils_in_yaml(self) -> None:
|
||||
"""Tests that the auto generated host.yaml has default settings in it"""
|
||||
for option_key, option_set in Utils.get_default_options().items():
|
||||
with self.subTest(option_key):
|
||||
self.assertIn(option_key, self.yaml_options)
|
||||
@@ -22,6 +23,7 @@ class TestIDs(unittest.TestCase):
|
||||
self.assertIn(sub_option_key, self.yaml_options[option_key])
|
||||
|
||||
def test_yaml_in_utils(self) -> None:
|
||||
"""Tests that the auto generated host.yaml shows up in reference calls"""
|
||||
utils_options = Utils.get_default_options()
|
||||
for option_key, option_set in self.yaml_options.items():
|
||||
with self.subTest(option_key):
|
||||
@@ -3,35 +3,37 @@ from worlds.AutoWorld import AutoWorldRegister
|
||||
|
||||
|
||||
class TestIDs(unittest.TestCase):
|
||||
def testUniqueItems(self):
|
||||
def test_unique_items(self):
|
||||
"""Tests that every game has a unique ID per item in the datapackage"""
|
||||
known_item_ids = set()
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
current = len(known_item_ids)
|
||||
known_item_ids |= set(world_type.item_id_to_name)
|
||||
self.assertEqual(len(known_item_ids) - len(world_type.item_id_to_name), current)
|
||||
|
||||
def testUniqueLocations(self):
|
||||
def test_unique_locations(self):
|
||||
"""Tests that every game has a unique ID per location in the datapackage"""
|
||||
known_location_ids = set()
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
current = len(known_location_ids)
|
||||
known_location_ids |= set(world_type.location_id_to_name)
|
||||
self.assertEqual(len(known_location_ids) - len(world_type.location_id_to_name), current)
|
||||
|
||||
def testRangeItems(self):
|
||||
def test_range_items(self):
|
||||
"""There are Javascript clients, which are limited to Number.MAX_SAFE_INTEGER due to 64bit float precision."""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
for item_id in world_type.item_id_to_name:
|
||||
self.assertLess(item_id, 2**53)
|
||||
|
||||
def testRangeLocations(self):
|
||||
def test_range_locations(self):
|
||||
"""There are Javascript clients, which are limited to Number.MAX_SAFE_INTEGER due to 64bit float precision."""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
for location_id in world_type.location_id_to_name:
|
||||
self.assertLess(location_id, 2**53)
|
||||
|
||||
def testReservedItems(self):
|
||||
def test_reserved_items(self):
|
||||
"""negative item IDs are reserved to the special "Archipelago" world."""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
@@ -42,7 +44,7 @@ class TestIDs(unittest.TestCase):
|
||||
for item_id in world_type.item_id_to_name:
|
||||
self.assertGreater(item_id, 0)
|
||||
|
||||
def testReservedLocations(self):
|
||||
def test_reserved_locations(self):
|
||||
"""negative location IDs are reserved to the special "Archipelago" world."""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
@@ -53,12 +55,14 @@ class TestIDs(unittest.TestCase):
|
||||
for location_id in world_type.location_id_to_name:
|
||||
self.assertGreater(location_id, 0)
|
||||
|
||||
def testDuplicateItemIDs(self):
|
||||
def test_duplicate_item_ids(self):
|
||||
"""Test that a game doesn't have item id overlap within its own datapackage"""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
self.assertEqual(len(world_type.item_id_to_name), len(world_type.item_name_to_id))
|
||||
|
||||
def testDuplicateLocationIDs(self):
|
||||
def test_duplicate_location_ids(self):
|
||||
"""Test that a game doesn't have location id overlap within its own datapackage"""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
self.assertEqual(len(world_type.location_id_to_name), len(world_type.location_name_to_id))
|
||||
@@ -5,7 +5,7 @@ from . import setup_solo_multiworld
|
||||
|
||||
|
||||
class TestImplemented(unittest.TestCase):
|
||||
def testCompletionCondition(self):
|
||||
def test_completion_condition(self):
|
||||
"""Ensure a completion condition is set that has requirements."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
if not world_type.hidden and game_name not in {"Sudoku"}:
|
||||
@@ -13,7 +13,7 @@ class TestImplemented(unittest.TestCase):
|
||||
multiworld = setup_solo_multiworld(world_type)
|
||||
self.assertFalse(multiworld.completion_condition[1](multiworld.state))
|
||||
|
||||
def testEntranceParents(self):
|
||||
def test_entrance_parents(self):
|
||||
"""Tests that the parents of created Entrances match the exiting Region."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
if not world_type.hidden:
|
||||
@@ -23,7 +23,7 @@ class TestImplemented(unittest.TestCase):
|
||||
for exit in region.exits:
|
||||
self.assertEqual(exit.parent_region, region)
|
||||
|
||||
def testStageMethods(self):
|
||||
def test_stage_methods(self):
|
||||
"""Tests that worlds don't try to implement certain steps that are only ever called as stage."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
if not world_type.hidden:
|
||||
@@ -4,7 +4,8 @@ from . import setup_solo_multiworld
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
def testCreateItem(self):
|
||||
def test_create_item(self):
|
||||
"""Test that a world can successfully create all items in its datapackage"""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
proxy_world = world_type(None, 0) # this is identical to MultiServer.py creating worlds
|
||||
for item_name in world_type.item_name_to_id:
|
||||
@@ -12,7 +13,7 @@ class TestBase(unittest.TestCase):
|
||||
item = proxy_world.create_item(item_name)
|
||||
self.assertEqual(item.name, item_name)
|
||||
|
||||
def testItemNameGroupHasValidItem(self):
|
||||
def test_item_name_group_has_valid_item(self):
|
||||
"""Test that all item name groups contain valid items. """
|
||||
# This cannot test for Event names that you may have declared for logic, only sendable Items.
|
||||
# In such a case, you can add your entries to this Exclusion dict. Game Name -> Group Names
|
||||
@@ -33,7 +34,7 @@ class TestBase(unittest.TestCase):
|
||||
for item in items:
|
||||
self.assertIn(item, world_type.item_name_to_id)
|
||||
|
||||
def testItemNameGroupConflict(self):
|
||||
def test_item_name_group_conflict(self):
|
||||
"""Test that all item name groups aren't also item names."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game_name, game_name=game_name):
|
||||
@@ -41,7 +42,8 @@ class TestBase(unittest.TestCase):
|
||||
with self.subTest(group_name, group_name=group_name):
|
||||
self.assertNotIn(group_name, world_type.item_name_to_id)
|
||||
|
||||
def testItemCountGreaterEqualLocations(self):
|
||||
def test_item_count_greater_equal_locations(self):
|
||||
"""Test that by the pre_fill step under default settings, each game submits items >= locations"""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest("Game", game=game_name):
|
||||
multiworld = setup_solo_multiworld(world_type)
|
||||
@@ -5,7 +5,7 @@ from . import setup_solo_multiworld
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
def testCreateDuplicateLocations(self):
|
||||
def test_create_duplicate_locations(self):
|
||||
"""Tests that no two Locations share a name or ID."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
multiworld = setup_solo_multiworld(world_type)
|
||||
@@ -20,7 +20,7 @@ class TestBase(unittest.TestCase):
|
||||
self.assertLessEqual(locations.most_common(1)[0][1], 1,
|
||||
f"{world_type.game} has duplicate of location ID {locations.most_common(1)}")
|
||||
|
||||
def testLocationsInDatapackage(self):
|
||||
def test_locations_in_datapackage(self):
|
||||
"""Tests that created locations not filled before fill starts exist in the datapackage."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest("Game", game_name=game_name):
|
||||
@@ -30,7 +30,7 @@ class TestBase(unittest.TestCase):
|
||||
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):
|
||||
def test_location_creation_steps(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():
|
||||
@@ -60,7 +60,7 @@ class TestBase(unittest.TestCase):
|
||||
self.assertGreaterEqual(location_count, len(multiworld.get_locations()),
|
||||
f"{game_name} modified locations count during pre_fill")
|
||||
|
||||
def testLocationGroup(self):
|
||||
def test_location_group(self):
|
||||
"""Test that all location name groups contain valid locations and don't share names."""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game_name, game_name=game_name):
|
||||
@@ -3,7 +3,7 @@ from worlds.AutoWorld import AutoWorldRegister
|
||||
|
||||
|
||||
class TestNames(unittest.TestCase):
|
||||
def testItemNamesFormat(self):
|
||||
def test_item_names_format(self):
|
||||
"""Item names must not be all numeric in order to differentiate between ID and name in !hint"""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
@@ -11,7 +11,7 @@ class TestNames(unittest.TestCase):
|
||||
self.assertFalse(item_name.isnumeric(),
|
||||
f"Item name \"{item_name}\" is invalid. It must not be numeric.")
|
||||
|
||||
def testLocationNameFormat(self):
|
||||
def test_location_name_format(self):
|
||||
"""Location names must not be all numeric in order to differentiate between ID and name in !hint_location"""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest(game=gamename):
|
||||
@@ -3,7 +3,8 @@ from worlds.AutoWorld import AutoWorldRegister
|
||||
|
||||
|
||||
class TestOptions(unittest.TestCase):
|
||||
def testOptionsHaveDocString(self):
|
||||
def test_options_have_doc_string(self):
|
||||
"""Test that submitted options have their own specified docstring"""
|
||||
for gamename, world_type in AutoWorldRegister.world_types.items():
|
||||
if not world_type.hidden:
|
||||
for option_key, option in world_type.options_dataclass.type_hints.items():
|
||||
@@ -31,7 +31,8 @@ class TestBase(unittest.TestCase):
|
||||
}
|
||||
}
|
||||
|
||||
def testDefaultAllStateCanReachEverything(self):
|
||||
def test_default_all_state_can_reach_everything(self):
|
||||
"""Ensure all state can reach everything and complete the game with the defined options"""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
unreachable_regions = self.default_settings_unreachable_regions.get(game_name, set())
|
||||
with self.subTest("Game", game=game_name):
|
||||
@@ -54,7 +55,8 @@ class TestBase(unittest.TestCase):
|
||||
with self.subTest("Completion Condition"):
|
||||
self.assertTrue(world.can_beat_game(state))
|
||||
|
||||
def testDefaultEmptyStateCanReachSomething(self):
|
||||
def test_default_empty_state_can_reach_something(self):
|
||||
"""Ensure empty state can reach at least one location with the defined options"""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
with self.subTest("Game", game=game_name):
|
||||
world = setup_solo_multiworld(world_type)
|
||||
Reference in New Issue
Block a user