From a934e17adc7f198ef672fa0f1c40dd77788f2f82 Mon Sep 17 00:00:00 2001 From: Theophile GENTILHOMME <tgentilhomme@jurasix08.idiap.ch> Date: Thu, 5 Jul 2018 11:04:46 +0200 Subject: [PATCH] Add more constraining test --- bob/extension/data/test_dump_config.py | 10 ++++++++++ bob/extension/test_click_helper.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 bob/extension/data/test_dump_config.py diff --git a/bob/extension/data/test_dump_config.py b/bob/extension/data/test_dump_config.py new file mode 100644 index 0000000..1db5b56 --- /dev/null +++ b/bob/extension/data/test_dump_config.py @@ -0,0 +1,10 @@ +## Configuration file automatically generated at 05/07/2018 for cli test. + + +## Path leading to test blablabla. +## Option: -t, --test [default: /my/path/test.txt] +# test = /my/path/test.txt + + + + diff --git a/bob/extension/test_click_helper.py b/bob/extension/test_click_helper.py index dbdbb28..cce211f 100644 --- a/bob/extension/test_click_helper.py +++ b/bob/extension/test_click_helper.py @@ -1,4 +1,5 @@ import click +import pkg_resources from click.testing import CliRunner from bob.extension.scripts.click_helper import ( verbosity_option, bool_option, list_float_option, @@ -178,7 +179,7 @@ def test_config_dump(): def cli(): pass - @click.command(cls=ConfigCommand) + @cli.command(cls=ConfigCommand) @click.option('-t', '--test', required=True, default="/my/path/test.txt", help="Path leading to test blablabla", cls=ResourceOption) @verbosity_option() @@ -186,5 +187,9 @@ def test_config_dump(): pass runner = CliRunner() with runner.isolated_filesystem(): - result = runner.invoke(cli, ['test', '-dc', 'TEST_CONF'], catch_exceptions=False) - assert result.exit_code != 0, (result.exit_code, result.output) + result = runner.invoke(cli, ['test', '-H', 'TEST_CONF'], catch_exceptions=False) + ref = pkg_resources.resource_filename('bob.extension', + 'data/test_dump_config.py') + assert result.exit_code == 0, (result.exit_code, result.output) + with open('TEST_CONF', 'r') as f, open(ref, 'r') as f2: + assert f.read() == f2.read() -- GitLab