fix: fix 'attribute-defined-outside-init' for pylint
This commit is contained in:
parent
d9db40fddc
commit
957c334d1d
8 changed files with 34 additions and 58 deletions
|
@ -17,7 +17,6 @@ from wuttjamaican.testing import FileTestCase, ConfigTestCase
|
|||
|
||||
|
||||
class TestWuttaConfig(FileTestCase):
|
||||
|
||||
def make_config(self, **kwargs):
|
||||
return mod.WuttaConfig(**kwargs)
|
||||
|
||||
|
@ -291,7 +290,6 @@ configure_logging = true
|
|||
)
|
||||
|
||||
with patch.object(conf.WuttaConfig, "_configure_logging") as method:
|
||||
|
||||
# no logging config by default
|
||||
config = conf.WuttaConfig()
|
||||
method.assert_not_called()
|
||||
|
@ -319,7 +317,6 @@ configure_logging = true
|
|||
)
|
||||
|
||||
with patch("wuttjamaican.conf.logging") as logging:
|
||||
|
||||
# basic constructor attempts logging config
|
||||
config = conf.WuttaConfig(configure_logging=True)
|
||||
logging.config.fileConfig.assert_called_once()
|
||||
|
@ -338,14 +335,14 @@ configure_logging = true
|
|||
logging.config.fileConfig.assert_called_once()
|
||||
|
||||
def test_config_has_no_app_after_init(self):
|
||||
|
||||
# initial config should *not* have an app yet, otherwise
|
||||
# extensions cannot specify a default app handler
|
||||
config = conf.WuttaConfig()
|
||||
self.assertFalse(hasattr(config, "_app"))
|
||||
self.assertIsNone(config._app)
|
||||
|
||||
# but after that we can get an app okay
|
||||
app = config.get_app()
|
||||
self.assertIsNotNone(app)
|
||||
self.assertIs(app, config._app)
|
||||
|
||||
def test_setdefault(self):
|
||||
|
@ -628,7 +625,6 @@ configure_logging = true
|
|||
self.assertEqual(value[2], "baz")
|
||||
|
||||
def test_get_app(self):
|
||||
|
||||
# default handler
|
||||
config = conf.WuttaConfig()
|
||||
self.assertEqual(config.default_app_handler_spec, "wuttjamaican.app:AppHandler")
|
||||
|
@ -686,7 +682,6 @@ def custom_make_engine_from_config():
|
|||
|
||||
|
||||
class TestWuttaConfigExtension(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
config = conf.WuttaConfig()
|
||||
ext = conf.WuttaConfigExtension()
|
||||
|
@ -695,7 +690,6 @@ class TestWuttaConfigExtension(TestCase):
|
|||
|
||||
|
||||
class TestGenericDefaultFiles(TestCase):
|
||||
|
||||
def test_linux(self):
|
||||
files = conf.generic_default_files("wuttatest")
|
||||
self.assertIsInstance(files, list)
|
||||
|
@ -707,7 +701,6 @@ class TestGenericDefaultFiles(TestCase):
|
|||
win32com.shell.SHGetSpecialFolderPath.return_value = r"C:" + os.sep
|
||||
with patch.dict("sys.modules", **{"win32com.shell": win32com}):
|
||||
with patch("wuttjamaican.conf.sys", platform="win32"):
|
||||
|
||||
files = conf.generic_default_files("wuttatest")
|
||||
self.assertIsInstance(files, list)
|
||||
self.assertTrue(len(files) > 1)
|
||||
|
@ -723,14 +716,12 @@ class TestGenericDefaultFiles(TestCase):
|
|||
|
||||
with patch("builtins.__import__", side_effect=mock_import):
|
||||
with patch("wuttjamaican.conf.sys", platform="win32"):
|
||||
|
||||
files = conf.generic_default_files("wuttatest")
|
||||
self.assertIsInstance(files, list)
|
||||
self.assertEqual(len(files), 0)
|
||||
|
||||
|
||||
class TestGetConfigPaths(FileTestCase):
|
||||
|
||||
def test_winsvc(self):
|
||||
myconf = self.write_file(
|
||||
"my.conf",
|
||||
|
@ -753,7 +744,6 @@ winsvc.RattailFileMonitor = /path/to/other/file
|
|||
|
||||
|
||||
class TestMakeConfig(FileTestCase):
|
||||
|
||||
# nb. we use appname='wuttatest' in this suite to avoid any
|
||||
# "valid" default config files, env vars etc. which may be present
|
||||
# on the dev machine
|
||||
|
@ -763,7 +753,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
with patch("wuttjamaican.conf.generic_default_files") as generic_default_files:
|
||||
with patch("wuttjamaican.conf.WuttaConfig") as WuttaConfig:
|
||||
|
||||
# generic files are used if nothing is specified
|
||||
generic_default_files.return_value = [generic]
|
||||
config = conf.make_config(appname="wuttatest")
|
||||
|
@ -788,7 +777,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
with patch("wuttjamaican.conf.generic_default_files") as generic_default_files:
|
||||
with patch("wuttjamaican.conf.WuttaConfig") as WuttaConfig:
|
||||
|
||||
# generic defaults are used if nothing specified
|
||||
generic_default_files.return_value = [generic]
|
||||
config = conf.make_config(appname="wuttatest")
|
||||
|
@ -832,7 +820,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
with patch("wuttjamaican.conf.generic_default_files") as generic_default_files:
|
||||
with patch("wuttjamaican.conf.WuttaConfig") as WuttaConfig:
|
||||
|
||||
generic_default_files.return_value = [generic]
|
||||
|
||||
# no plus files by default
|
||||
|
@ -877,7 +864,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
with patch("wuttjamaican.conf.generic_default_files") as generic_default_files:
|
||||
with patch("wuttjamaican.conf.WuttaConfig") as WuttaConfig:
|
||||
|
||||
generic_default_files.return_value = [generic]
|
||||
|
||||
# generic files by default
|
||||
|
@ -922,7 +908,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
with patch.object(mod, "WuttaConfig") as WuttaConfig:
|
||||
with patch.object(mod, "load_entry_points") as load_entry_points:
|
||||
|
||||
# no entry points loaded if extend=False
|
||||
config = mod.make_config(appname="wuttatest", extend=False)
|
||||
WuttaConfig.assert_called_once_with(
|
||||
|
@ -967,7 +952,6 @@ class TestMakeConfig(FileTestCase):
|
|||
|
||||
|
||||
class TestWuttaConfigProfile(ConfigTestCase):
|
||||
|
||||
def make_profile(self, key):
|
||||
return mod.WuttaConfigProfile(self.config, key)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue