From 447b7d122edf4e768f1f4e7648fa159275153384 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 1 Sep 2020 18:31:38 +0800 Subject: [PATCH] ceph_deploy: replace ConfigParser.readfp() with read_file() for silencing the warnings like DeprecationWarning: This method will be removed in future versions. Use 'parser.read_file()' instead. Signed-off-by: Kefu Chai --- ceph_deploy/conf/ceph.py | 2 +- ceph_deploy/tests/unit/test_conf.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ceph_deploy/conf/ceph.py b/ceph_deploy/conf/ceph.py index 4c2f51a..b9cefe1 100644 --- a/ceph_deploy/conf/ceph.py +++ b/ceph_deploy/conf/ceph.py @@ -43,7 +43,7 @@ class CephConf(configparser.RawConfigParser): def parse(fp): cfg = CephConf() ifp = _TrimIndentFile(fp) - cfg.readfp(ifp) + cfg.read_file(ifp) return cfg diff --git a/ceph_deploy/tests/unit/test_conf.py b/ceph_deploy/tests/unit/test_conf.py index c0a3521..685acbb 100644 --- a/ceph_deploy/tests/unit/test_conf.py +++ b/ceph_deploy/tests/unit/test_conf.py @@ -82,7 +82,7 @@ class TestConfGetList(object): [foo] key = """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == [''] def test_get_list_empty_when_no_key(self): @@ -90,7 +90,7 @@ class TestConfGetList(object): conf_file = StringIO(dedent(""" [foo] """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == [] def test_get_list_if_value_is_one_item(self): @@ -99,7 +99,7 @@ class TestConfGetList(object): [foo] key = 1 """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == ['1'] def test_get_list_with_mutltiple_items(self): @@ -108,7 +108,7 @@ class TestConfGetList(object): [foo] key = 1, 3, 4 """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == ['1', '3', '4'] def test_get_rid_of_comments(self): @@ -117,7 +117,7 @@ class TestConfGetList(object): [foo] key = 1, 3, 4 # this is a wonderful comment y'all """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == ['1', '3', '4'] def test_get_rid_of_whitespace(self): @@ -126,7 +126,7 @@ class TestConfGetList(object): [foo] key = 1, 3 , 4 """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_list('foo', 'key') == ['1', '3', '4'] def test_get_default_repo(self): @@ -135,7 +135,7 @@ class TestConfGetList(object): [foo] default = True """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_default_repo() == 'foo' def test_get_default_repo_fails_non_truthy(self): @@ -144,7 +144,7 @@ class TestConfGetList(object): [foo] default = 0 """)) - cfg.readfp(conf_file) + cfg.read_file(conf_file) assert cfg.get_default_repo() is False -- 2.47.3