From cf4e81233430a70252180aa7c10868c19510f73c Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 2 Nov 2020 12:27:02 +0200 Subject: [PATCH] Allow TestProcess subclasses set home dir, use mkdtemp for test_config --- src/tests/test_config.py | 2 ++ src/tests/test_process.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tests/test_config.py b/src/tests/test_config.py index 35ddd3fa..508c4394 100644 --- a/src/tests/test_config.py +++ b/src/tests/test_config.py @@ -4,6 +4,7 @@ Various tests for config import os import unittest +import tempfile from pybitmessage.bmconfigparser import BMConfigParser from test_process import TestProcessProto @@ -41,6 +42,7 @@ class TestConfig(unittest.TestCase): class TestProcessConfig(TestProcessProto): """A test case for keys.dat""" + home = tempfile.mkdtemp() def test_config_defaults(self): """Test settings in the generated config""" diff --git a/src/tests/test_process.py b/src/tests/test_process.py index 3e9d326b..f70c4d03 100644 --- a/src/tests/test_process.py +++ b/src/tests/test_process.py @@ -28,12 +28,16 @@ class TestProcessProto(unittest.TestCase): 'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat', '.api_started', 'unittest.lock' ) + home = None @classmethod def setUpClass(cls): """Setup environment and start pybitmessage""" cls.flag = False - cls.home = os.environ['BITMESSAGE_HOME'] = tempfile.gettempdir() + if not cls.home: + cls.home = tempfile.gettempdir() + cls._cleanup_files() + os.environ['BITMESSAGE_HOME'] = cls.home put_signal_file(cls.home, 'unittest.lock') subprocess.Popen( cls._process_cmd,