Get rid of config global state, improve tests
While dicking around with the tests I noticed that you could make them fail if you ran them twice. Many hours were spent investigating, and it turns out that Overviewer's config stuff has global state that gets modified by having parsed configurations actually modify the default config values. Not good! We can fix this by having settingsDefinition return a dict of the defaults, instead of assigning it to module-level names. We can also get rid of test_all.py, because what it would do with pytest is run all tests *twice*. Instead, do the module path stuff in __init__.py. Also, instead of throwing a non-specific Exception if exmaple isn't checked out, just skip the test thank you very much. This is the weirdest rabbit hole I've ever gone down and I haven't slept in about 30 hours. I'm going to push this commit, and if it breaks anything, I'll be blissfully asleep as the unwashed masses begin to riot over exception this traceback that.
This commit is contained in:
@@ -33,8 +33,9 @@ class MultiWorldParser:
|
||||
# This maps setting names to their values as given in
|
||||
# settingsDefinition.py
|
||||
self._settings = {}
|
||||
for settingname in dir(settingsDefinition):
|
||||
setting = getattr(settingsDefinition, settingname)
|
||||
default_conf = settingsDefinition.get_default_config()
|
||||
for settingname in default_conf:
|
||||
setting = default_conf[settingname]
|
||||
if not isinstance(setting, settingsValidators.Setting):
|
||||
continue
|
||||
|
||||
@@ -79,7 +80,6 @@ class MultiWorldParser:
|
||||
# The global environment should be the rendermode module, so the config
|
||||
# file has access to those resources.
|
||||
from . import rendermodes
|
||||
|
||||
try:
|
||||
with open(settings_file, "rb") as settings_file_handle:
|
||||
exec(compile(settings_file_handle.read(), settings_file, 'exec'),
|
||||
|
||||
Reference in New Issue
Block a user