mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 04:01:32 -06:00
Core: Add restricted_dumps
helper (#5117)
* Add pickling helper that check unpicklability * Add test condition and generation error handling * Fix incorrect call and make imports consistent * Fix newline padding * Change PicklingError to directly caused by UnpicklingError Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * Revert to `pickle.dumps` for decompressed multidata * Fix import order * Restore pickle import in main * Re-add for multidata in Main * Remove multisave checks * Update MultiServer.py * Update customserver.py --------- Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import unittest
|
||||
|
||||
from BaseClasses import MultiWorld, PlandoOptions
|
||||
from Options import ItemLinks
|
||||
from BaseClasses import PlandoOptions
|
||||
from Options import ItemLinks, Choice
|
||||
from Utils import restricted_dumps
|
||||
from worlds.AutoWorld import AutoWorldRegister
|
||||
|
||||
|
||||
@@ -73,9 +74,10 @@ class TestOptions(unittest.TestCase):
|
||||
|
||||
def test_pickle_dumps(self):
|
||||
"""Test options can be pickled into database for WebHost generation"""
|
||||
import pickle
|
||||
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():
|
||||
with self.subTest(game=gamename, option=option_key):
|
||||
pickle.dumps(option.from_any(option.default))
|
||||
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]))
|
||||
|
Reference in New Issue
Block a user