mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-27 23:13:23 -07:00
Options: support "random" and variations for OptionSet with defined valid_keys (#4418)
* seemingly works? needs testing * attempt docs update * move to verify resolution (keep?) * account for no valid keys and "random" being passed * Update advanced_settings_en.md * Update Options.py Co-authored-by: qwint <qwint.42@gmail.com> * Update Options.py Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * unify random handling between range and set * Update Options.py * Update Options.py * Update Options.py Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * super is weird * fix item/location * remove groups from options * unittest * pep8 * Update Options.py Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> * Update Options.py --------- Co-authored-by: qwint <qwint.42@gmail.com> Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import unittest
|
||||
|
||||
from BaseClasses import PlandoOptions
|
||||
from Options import Choice, ItemLinks, PlandoConnections, PlandoItems, PlandoTexts
|
||||
from Options import Choice, ItemLinks, OptionSet, PlandoConnections, PlandoItems, PlandoTexts
|
||||
from Utils import restricted_dumps
|
||||
|
||||
from worlds.AutoWorld import AutoWorldRegister
|
||||
|
||||
|
||||
@@ -81,6 +82,19 @@ class TestOptions(unittest.TestCase):
|
||||
restricted_dumps(option.from_any(option.default))
|
||||
if issubclass(option, Choice) and option.default in option.name_lookup:
|
||||
restricted_dumps(option.from_text(option.name_lookup[option.default]))
|
||||
|
||||
def test_option_set_keys_random(self):
|
||||
"""Tests that option sets do not contain 'random' and its variants as valid keys"""
|
||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||
if game_name not in ("Archipelago", "Sudoku", "Super Metroid"):
|
||||
for option_key, option in world_type.options_dataclass.type_hints.items():
|
||||
if issubclass(option, OptionSet):
|
||||
with self.subTest(game=game_name, option=option_key):
|
||||
self.assertFalse(any(random_key in option.valid_keys for random_key in ("random",
|
||||
"random-high",
|
||||
"random-low")))
|
||||
for key in option.valid_keys:
|
||||
self.assertFalse("random-range" in key)
|
||||
|
||||
def test_pickle_dumps_plando(self):
|
||||
"""Test that plando options using containers of a custom type can be pickled"""
|
||||
|
||||
Reference in New Issue
Block a user