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"""
|
||||
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()
|
||||
|
|
|
@ -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,6 +47,7 @@ class TestConfig(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""restore to the backup of BMConfigparser"""
|
||||
# pylint: protected-access=ignore
|
||||
BMConfigParser()._reset()
|
||||
BMConfigParser().readfp(self.configfile)
|
||||
|
||||
|
@ -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)
|
||||
|
|
Reference in New Issue
Block a user