diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index ae0b46fe..13a20fa0 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -165,6 +165,13 @@ class BMConfigParser(SafeConfigParser): but override the "raw" argument to always True""" return SafeConfigParser.items(self, section, True, variables) + def _reset(self): + """Reset current config. There doesn't appear to be a built in + method for this""" + sections = self.sections() + for x in sections: + self.remove_section(x) + if sys.version_info[0] == 3: @staticmethod def addresses(hidden=False): @@ -172,13 +179,6 @@ class BMConfigParser(SafeConfigParser): return [x for x in BMConfigParser().sections() if x.startswith('BM-') and ( hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))] - def _reset(self): - """Reset current config. There doesn't appear to be a built in - method for this""" - sections = self.sections() - for x in sections: - self.remove_section(x) - def read(self, filenames): self._reset() SafeConfigParser.read(self, filenames) @@ -200,8 +200,9 @@ class BMConfigParser(SafeConfigParser): except configparser.InterpolationError: continue - def readfp(self, file_obj): - SafeConfigParser.read_file(self, file_obj) + def readfp(self, fp, filename=None): + # pylint: no-member=ignore + SafeConfigParser.read_file(self, fp) else: @staticmethod def addresses(): @@ -209,13 +210,6 @@ class BMConfigParser(SafeConfigParser): return [ x for x in BMConfigParser().sections() if x.startswith('BM-')] - def _reset(self): - """Reset current config. There doesn't appear to be a built in - method for this""" - sections = self.sections() - for x in sections: - self.remove_section(x) - def read(self, filenames): """Read config and populate defaults""" self._reset() diff --git a/src/tests/test_config.py b/src/tests/test_config.py index dcde4e6f..671f4db7 100644 --- a/src/tests/test_config.py +++ b/src/tests/test_config.py @@ -3,12 +3,8 @@ Various tests for config """ import unittest -import tempfile -import sys -import os from six import StringIO -from pybitmessage import paths from pybitmessage.bmconfigparser import BMConfigParser test_config = """[bitmessagesettings] @@ -51,7 +47,8 @@ class TestConfig(unittest.TestCase): def tearDown(self): """restore to the backup of BMConfigparser""" - BMConfigParser()._reset() + # pylint: protected-access=ignore + BMConfigParser()._reset() BMConfigParser().readfp(self.configfile) def test_safeGet(self): @@ -68,6 +65,7 @@ class TestConfig(unittest.TestCase): False ) # no arg for default + # pylint: disable=too-many-function-args with self.assertRaises(TypeError): BMConfigParser().safeGetBoolean( 'nonexistent', 'nonexistent', True) @@ -93,7 +91,7 @@ class TestConfig(unittest.TestCase): self.assertEqual( BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100) - + # pylint: protected-access=ignore BMConfigParser()._reset() self.assertEqual( BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)