0

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:
Nicolas F
2019-07-24 17:02:39 +02:00
parent 0bb823599d
commit 0d3d630104
7 changed files with 70 additions and 104 deletions

View File

@@ -5,15 +5,10 @@ import os
from overviewer_core import world
class ExampleWorldTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Make sure that test/data/worlds/example exists
# if it doesn't, then give a little
if not os.path.exists("test/data/worlds/exmaple"):
raise Exception("test data doesn't exist. Maybe you need to init/update your submodule?")
def test_basic(self):
"Basic test of the world constructor and regionset constructor"
if not os.path.exists("test/data/worlds/exmaple"):
raise unittest.SkipTest("test data doesn't exist. Maybe you need to init/update your submodule?")
w = world.World("test/data/worlds/exmaple")
regionsets = w.get_regionsets()