diff --git a/.gitignore b/.gitignore index 917675d..908095e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,10 @@ pip-log.txt # Unit test / coverage reports .coverage +htmlcov .tox nosetests.xml +.cache # Translations *.mo diff --git a/gooey/tests/argparse_to_json_unittest.py b/gooey/tests/argparse_to_json_unittest.py index 71be3b6..9c6332d 100644 --- a/gooey/tests/argparse_to_json_unittest.py +++ b/gooey/tests/argparse_to_json_unittest.py @@ -158,6 +158,15 @@ def test_mutually(exclusive_group): assert target_arg.dest == data['display_name'] +def test_empty_mutex_group(): + assert not build_radio_group(None) + + +def test_as_json_invalid_widget(): + with pytest.raises(UnknownWidgetType): + as_json(None, 'InvalidWidget', None) + + def get_action(parser, dest): for action in parser._actions: if action.dest == dest: @@ -168,11 +177,3 @@ def find_arg_by_option(group, option_string): for arg in group: if option_string in arg.option_strings: return arg - - - - - - - - diff --git a/gooey/tests/config_generator_unittest.py b/gooey/tests/config_generator_unittest.py new file mode 100644 index 0000000..887de9f --- /dev/null +++ b/gooey/tests/config_generator_unittest.py @@ -0,0 +1,20 @@ +import argparse +import pytest +from gooey.python_bindings.config_generator import * + +# TODO: duplicated from argparse_to_json_unittest, should go into conftest.py +@pytest.fixture +def empty_parser(): + return argparse.ArgumentParser(description='description') + + +def test_create_from_parser(empty_parser): + build_spec = create_from_parser(empty_parser,'.') + assert build_spec['manual_start'] == True + + +def test_create_from_parser_show_config(empty_parser): + build_spec = create_from_parser(empty_parser, + '.', + show_config=True) + assert build_spec['program_description'] == 'description'