Tests: have option preset validation test do full validation (#4208)

* Tests: have option preset validation test do full validation

* sum on an IntFlag is a thing apparently
This commit is contained in:
Aaron Wagener 2024-11-18 11:09:27 -06:00 committed by GitHub
parent 3ae8992fb6
commit 85a713771b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import unittest
from BaseClasses import PlandoOptions
from worlds import AutoWorldRegister
from Options import ItemDict, NamedRange, NumericOption, OptionList, OptionSet
@ -14,6 +15,10 @@ class TestOptionPresets(unittest.TestCase):
with self.subTest(game=game_name, preset=preset_name, option=option_name):
try:
option = world_type.options_dataclass.type_hints[option_name].from_any(option_value)
# some options may need verification to ensure the provided option is actually valid
# pass in all plando options in case a preset wants to require certain plando options
# for some reason
option.verify(world_type, "Test Player", PlandoOptions(sum(PlandoOptions)))
supported_types = [NumericOption, OptionSet, OptionList, ItemDict]
if not any([issubclass(option.__class__, t) for t in supported_types]):
self.fail(f"'{option_name}' in preset '{preset_name}' for game '{game_name}' "