def test_call_nosection(tmpdir): conffile = tmpdir.join('config') conffile.write("testvalue = True") provider = configobj_provider() rv = provider(conffile, 'name') assert 'testvalue' in rv assert rv['testvalue'] is True
def test_call_missing_section(tmpdir): conffile = tmpdir.join('config') conffile.write(""" testvalue = True """) provider = configobj_provider(section='mysection') rv = provider(conffile, 'name') assert 'testvalue' not in rv
def test_call_section(tmpdir): conffile = tmpdir.join('config') conffile.write(""" [mysection] testvalue = True """) provider = configobj_provider(section='mysection') rv = provider(None, conffile, 'name') assert 'testvalue' in rv assert rv['testvalue'] is True
def test_init_defaults(): provider = configobj_provider() assert provider.unrepr is True assert provider.section is None
def test_call_broken_file(tmpdir): conffile = tmpdir.join('config') conffile.write("Ceci n'est pas un ConfigObj.") provider = configobj_provider() with pytest.raises(configobj.ParseError): provider(conffile, 'name')
def test_call_missing_file(tmpdir): nofile = tmpdir.join("nosuchfile") provider = configobj_provider() with pytest.raises(py.error.ENOENT): provider(nofile, 'name')
def test_init_kwargs(): provider = configobj_provider(unrepr=False, section='Test') assert provider.unrepr is False assert provider.section == 'Test'
import click import click_config_file from environs import Env env = Env() env.read_env() # read .env file, if it exists provider = click_config_file.configobj_provider(section="adr", unrepr=False) @click.group() def cli(): """ Manage Architectural Decision Records """ pass @cli.command() @click.option( "--directory", "-d", default="./doc/adr", type=click.Path(file_okay=False, dir_okay=True, writable=True, resolve_path=True), ) @click.option("--template", "-t", type=click.Path(dir_okay=False, resolve_path=True)) @click.pass_context