1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
# Copyright (c) 2017-2019 David Steele <dsteele@gmail.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# License-Filename: LICENSE
import pytest
import textwrap
import os
from comitup import config
@pytest.fixture()
def conf_fxt(tmpdir):
path = os.path.join(tmpdir.__str__(), "conf.conf")
with open(path, 'w') as fp:
fp.write(
textwrap.dedent(
"""
#
# comment
#
tag1=val1
tag2: val2
tag3 = val3
# tag4 = val4
"""
)
)
return config.Config(path)
@pytest.mark.parametrize("idx", ('1', '2', '3'))
def test_conf_vals(idx, conf_fxt):
assert eval('conf_fxt.tag{0} == "val{0}"'.format(idx))
def test_conf_miss(conf_fxt):
with pytest.raises(AttributeError):
conf_fxt.tag4
|