tabbed_conf = """
[global]
default = 0
+ other_h = 1 # comment
+ other_c = 1 ; comment
+ colon = ;
+ hash = #
"""
result = configuration.load(conf_path)
assert result.get('global', 'default') == '0'
+ def test_load_with_colon_comments(self, tmpdir):
+ conf_path = os.path.join(str(tmpdir), 'ceph.conf')
+ with open(conf_path, 'w') as conf:
+ conf.write(tabbed_conf)
+ result = configuration.load(conf_path)
+ assert result.get('global', 'other_c') == '1'
+
+ def test_load_with_hash_comments(self, tmpdir):
+ conf_path = os.path.join(str(tmpdir), 'ceph.conf')
+ with open(conf_path, 'w') as conf:
+ conf.write(tabbed_conf)
+ result = configuration.load(conf_path)
+ assert result.get('global', 'other_h') == '1'
+
def test_path_does_not_exist(self):
with pytest.raises(exceptions.ConfigurationError):
conf = configuration.load('/path/does/not/exist/ceph.con')
configuration.load(ceph_conf)
stdout, stderr = capsys.readouterr()
assert 'File contains no section headers' in stdout
+
+ @pytest.mark.parametrize('commented', ['colon','hash'])
+ def test_coment_as_a_value(self, tmpdir, commented):
+ conf_path = os.path.join(str(tmpdir), 'ceph.conf')
+ with open(conf_path, 'w') as conf:
+ conf.write(tabbed_conf)
+ result = configuration.load(conf_path)
+ assert result.get('global', commented) == ''