From 14f1c15945d023e40b7d3b96b9fd42ea1cfdfa98 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Fri, 17 Sep 2021 20:27:02 +0530 Subject: [PATCH] Fixed test_config.ini file path error --- src/bmconfigparser.py | 1 + src/tests/test_config.py | 16 ++++++++++------ src/tests/test_pattern/test_config.ini | 0 3 files changed, 11 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/tests/test_pattern/test_config.ini diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index 5d6ea5d4..1c830ab8 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -180,6 +180,7 @@ class BMConfigParser(SafeConfigParser): self.remove_section(x) def read(self, filenames): + self._reset() SafeConfigParser.read(self, filenames) for section in self.sections(): for option in self.options(section): diff --git a/src/tests/test_config.py b/src/tests/test_config.py index efcf78a3..2c52c73c 100644 --- a/src/tests/test_config.py +++ b/src/tests/test_config.py @@ -7,7 +7,7 @@ import tempfile import sys import os -# from six.moves import configparser +from pybitmessage import paths from pybitmessage.bmconfigparser import BMConfigParser test_config = { @@ -91,13 +91,17 @@ class TestConfig(unittest.TestCase): def test_reset(self): """safeGetInt retuns provided default for bitmessagesettings option or 0""" - if sys.version_info[0] >= 3: - BMConfigParser().read_dict(test_config) - else: - BMConfigParser().read('src/tests/test_config.ini') + + BMConfigParser().read( + os.path.join( + os.path.abspath(os.path.dirname(__file__)), + 'test_pattern', 'test_config.ini' + ) + ) + self.assertEqual( BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100) - # pylint: disable=protected-access + BMConfigParser()._reset() self.assertEqual( BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500) diff --git a/src/tests/test_pattern/test_config.ini b/src/tests/test_pattern/test_config.ini old mode 100644 new mode 100755