diff --git a/test/general/test_ids.py b/test/general/test_ids.py index 4edfb8d994ef..f6d8f9ba63a2 100644 --- a/test/general/test_ids.py +++ b/test/general/test_ids.py @@ -6,7 +6,7 @@ class TestIDs(unittest.TestCase): 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(): + for world_type in AutoWorldRegister.world_types.values(): 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) @@ -14,7 +14,7 @@ def test_unique_items(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(): + for world_type in AutoWorldRegister.world_types.values(): 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) @@ -59,10 +59,24 @@ 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)) + overlap = False + if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): + overlap = \ + set(world_type.item_id_to_name.values()) \ + .symmetric_difference(set(world_type.item_name_to_id.keys())) or \ + set(world_type.item_id_to_name.keys()) \ + .symmetric_difference(set(world_type.item_name_to_id.values())) + self.assertFalse(overlap) 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)) + overlap = False + if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): + overlap = \ + set(world_type.location_id_to_name.values()) \ + .symmetric_difference(set(world_type.location_name_to_id.keys())) or \ + set(world_type.location_id_to_name.keys()) \ + .symmetric_difference(set(world_type.location_name_to_id.values())) + self.assertFalse(overlap)