From 5d23b38bf31a570bcd6fdf6cacaf1d2460e70af4 Mon Sep 17 00:00:00 2001 From: spl0k Date: Mon, 27 Nov 2017 22:55:18 +0100 Subject: [PATCH] Tests use a temporary cache directory --- tests/testbase.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/testbase.py b/tests/testbase.py index ec4ad6f..8977042 100644 --- a/tests/testbase.py +++ b/tests/testbase.py @@ -9,8 +9,10 @@ # Distributed under terms of the GNU AGPLv3 license. import io +import shutil import sys import unittest +import tempfile from supysonic.config import DefaultConfig from supysonic.managers.user import UserManager @@ -41,7 +43,11 @@ class TestBase(unittest.TestCase): __with_api__ = False def setUp(self): - app = create_application(TestConfig(self.__with_webui__, self.__with_api__)) + self.__dir = tempfile.mkdtemp() + config = TestConfig(self.__with_webui__, self.__with_api__) + config.WEBAPP['cache_dir'] = self.__dir + + app = create_application(config) self.__ctx = app.app_context() self.__ctx.push() @@ -58,6 +64,7 @@ class TestBase(unittest.TestCase): def tearDown(self): self.__ctx.pop() + shutil.rmtree(self.__dir) to_unload = [ m for m in sys.modules if m.startswith('supysonic') ] for m in to_unload: