]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
ceph_deploy: replace ConfigParser.readfp() with read_file()
authorKefu Chai <kchai@redhat.com>
Tue, 1 Sep 2020 10:31:38 +0000 (18:31 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 1 Sep 2020 10:31:39 +0000 (18:31 +0800)
for silencing the warnings like

DeprecationWarning: This method will be removed in future versions.  Use 'parser.read_file()' instead.

Signed-off-by: Kefu Chai <kchai@redhat.com>
ceph_deploy/conf/ceph.py
ceph_deploy/tests/unit/test_conf.py

index 4c2f51a65f6c50296413153e48fbba9247adebd7..b9cefe119cfc9d16b62e228a8be5a95ecb3cdf88 100644 (file)
@@ -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
 
 
index c0a3521578bf98b490f8eaee31ee0066c8f683c4..685acbb5487876cda405ee6ba0069e7e66c8209f 100644 (file)
@@ -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