Reformated _reset method placement, Fixed pylint issues & reverted pylint ignore comment delete changes
This commit is contained in:
parent
4f9593a553
commit
a3dceb8b3e
|
@ -165,6 +165,13 @@ class BMConfigParser(SafeConfigParser):
|
||||||
but override the "raw" argument to always True"""
|
but override the "raw" argument to always True"""
|
||||||
return SafeConfigParser.items(self, section, True, variables)
|
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:
|
if sys.version_info[0] == 3:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addresses(hidden=False):
|
def addresses(hidden=False):
|
||||||
|
@ -172,13 +179,6 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (
|
return [x for x in BMConfigParser().sections() if x.startswith('BM-') and (
|
||||||
hidden or not BMConfigParser().safeGetBoolean(x, 'hidden'))]
|
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):
|
def read(self, filenames):
|
||||||
self._reset()
|
self._reset()
|
||||||
SafeConfigParser.read(self, filenames)
|
SafeConfigParser.read(self, filenames)
|
||||||
|
@ -200,8 +200,9 @@ class BMConfigParser(SafeConfigParser):
|
||||||
except configparser.InterpolationError:
|
except configparser.InterpolationError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def readfp(self, file_obj):
|
def readfp(self, fp, filename=None):
|
||||||
SafeConfigParser.read_file(self, file_obj)
|
# pylint: no-member=ignore
|
||||||
|
SafeConfigParser.read_file(self, fp)
|
||||||
else:
|
else:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addresses():
|
def addresses():
|
||||||
|
@ -209,13 +210,6 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return [
|
return [
|
||||||
x for x in BMConfigParser().sections() if x.startswith('BM-')]
|
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):
|
def read(self, filenames):
|
||||||
"""Read config and populate defaults"""
|
"""Read config and populate defaults"""
|
||||||
self._reset()
|
self._reset()
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
Various tests for config
|
Various tests for config
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from six import StringIO
|
from six import StringIO
|
||||||
from pybitmessage import paths
|
|
||||||
from pybitmessage.bmconfigparser import BMConfigParser
|
from pybitmessage.bmconfigparser import BMConfigParser
|
||||||
|
|
||||||
test_config = """[bitmessagesettings]
|
test_config = """[bitmessagesettings]
|
||||||
|
@ -51,7 +47,8 @@ class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""restore to the backup of BMConfigparser"""
|
"""restore to the backup of BMConfigparser"""
|
||||||
BMConfigParser()._reset()
|
# pylint: protected-access=ignore
|
||||||
|
BMConfigParser()._reset()
|
||||||
BMConfigParser().readfp(self.configfile)
|
BMConfigParser().readfp(self.configfile)
|
||||||
|
|
||||||
def test_safeGet(self):
|
def test_safeGet(self):
|
||||||
|
@ -68,6 +65,7 @@ class TestConfig(unittest.TestCase):
|
||||||
False
|
False
|
||||||
)
|
)
|
||||||
# no arg for default
|
# no arg for default
|
||||||
|
# pylint: disable=too-many-function-args
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
BMConfigParser().safeGetBoolean(
|
BMConfigParser().safeGetBoolean(
|
||||||
'nonexistent', 'nonexistent', True)
|
'nonexistent', 'nonexistent', True)
|
||||||
|
@ -93,7 +91,7 @@ class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
||||||
|
# pylint: protected-access=ignore
|
||||||
BMConfigParser()._reset()
|
BMConfigParser()._reset()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
||||||
|
|
Reference in New Issue
Block a user