Browse Source

Add more tests to raise test coverage.

pull/129/head
Christoph Buchner 9 years ago
parent
commit
2799d54f16
3 changed files with 31 additions and 8 deletions
  1. 2
      .gitignore
  2. 17
      gooey/tests/argparse_to_json_unittest.py
  3. 20
      gooey/tests/config_generator_unittest.py

2
.gitignore

@ -23,8 +23,10 @@ pip-log.txt
# Unit test / coverage reports # Unit test / coverage reports
.coverage .coverage
htmlcov
.tox .tox
nosetests.xml nosetests.xml
.cache
# Translations # Translations
*.mo *.mo

17
gooey/tests/argparse_to_json_unittest.py

@ -158,6 +158,15 @@ def test_mutually(exclusive_group):
assert target_arg.dest == data['display_name'] 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): def get_action(parser, dest):
for action in parser._actions: for action in parser._actions:
if action.dest == dest: if action.dest == dest:
@ -168,11 +177,3 @@ def find_arg_by_option(group, option_string):
for arg in group: for arg in group:
if option_string in arg.option_strings: if option_string in arg.option_strings:
return arg return arg

20
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'
Loading…
Cancel
Save