-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathtest_api.py
More file actions
30 lines (19 loc) · 925 Bytes
/
test_api.py
File metadata and controls
30 lines (19 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
import cowsay
def test_char_names():
characters = ['beavis', 'cheese', 'daemon', 'cow', 'dragon',
'ghostbusters', 'kitty', 'mashiro', 'meow', 'milk', 'stegosaurus',
'stimpy', 'turkey', 'turtle', 'tux',
'pig', 'trex', 'miki', 'fox', 'octopus']
assert len(cowsay.char_names) == len(characters)
assert cowsay.char_names == sorted(characters)
def test_draw_error():
with pytest.raises(cowsay.CowsayError) as e:
cowsay.draw('', '')
assert e.value.args[0] == 'Pass something meaningful to cowsay'
def test_get_output_string():
assert isinstance(cowsay.get_output_string(char='cow', text='Hello'), str)
def test_get_output_string_error():
with pytest.raises(cowsay.CowsayError) as e:
cowsay.get_output_string('random', 'random text')
assert e.value.args[0] == f'Available Characters: {cowsay.char_names}'