Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 22, 2013
1 parent 6802bf4 commit 01d7d5a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def test_styles():
print(terminal.bold(terminal.underline('bold and underline style')))


@raises(ValueError)
def test_hex2ansi():
terminal.hex2ansi('ffbbccd')


class TestColor(object):
def test_property(self):
s = terminal.Color('text')
Expand All @@ -61,6 +66,11 @@ def test_property(self):
s.bgcolor = 'd64'
print(s)

@raises(AttributeError)
def test_property_raise(self):
s = terminal.Color('text')
print(s.unknown)

def test_plus(self):
foo = terminal.Color('foo')
print(foo.green + 'bar')
Expand Down
19 changes: 19 additions & 0 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def test_parse(self):
assert program.color is False
assert program.key == 'what'

def test_print(self):
program = Command('foo', title='foobar', version='1.0.0')
program.print_version()
program.print_help()

program._usage = 'foo [options]'
program.print_help()

def test_action(self):
program = Command('foo')

Expand Down Expand Up @@ -129,6 +137,8 @@ def test_call(self):
def bar():
return 'bar'

program.print_help()

# bar is a pure function subcommand
program.parse('foo bar baz')
# bar can not parse args
Expand All @@ -148,3 +158,12 @@ def test_get_default(self):
program = Command('foo')
program.option('--output [dir]', 'output dir, default: site')
assert program.output == 'site'

def test_run_parse(self):
program = Command('foo')

def func(**kwargs):
print('func')

program._command_func = func
program.parse()
3 changes: 3 additions & 0 deletions tests/test_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ def test_choose():
patch(lambda name: 'none')
rv = choose('foo', ['a', 'b'])
assert rv is None

patch(lambda name: 'b')
choose('foo', ['a', ('b', 'bar')])

0 comments on commit 01d7d5a

Please sign in to comment.