-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_randomdef.py
63 lines (51 loc) · 1.96 KB
/
test_randomdef.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pytest
from randomdef import randomDefinition
def test_noexample_nosubset(capsys):
testObject = randomDefinition('test', showexample=False, subset=False)
testObject.get_synset()
testObject.print_output()
out, err = capsys.readouterr()
defstring = "The definition of {0} is:".format(testObject.inword)
assert defstring in out
assert testObject.example is None
assert err == ''
def test_example_nosubset(capsys):
testObject = randomDefinition('test', showexample=True, subset=False)
testObject.get_synset()
testObject.print_output()
out, err = capsys.readouterr()
defstring = "The definition of {0} is:".format(testObject.inword)
assert defstring in out
assert "Example: " in out or "No examples available" in out
assert err == ''
def test_noexample_subset(capsys):
testObject = randomDefinition('test', showexample=False, subset=True)
testObject.get_synset()
testObject.print_output()
out, err = capsys.readouterr()
defstring = "The definition of {0} is:".format(testObject.inword)
assert defstring in out
assert testObject.example is None
assert err == ''
def test_example_subset(capsys):
testObject = randomDefinition('test', showexample=True, subset=True)
testObject.get_synset()
testObject.print_output()
out, err = capsys.readouterr()
defstring = "The definition of {0} is:".format(testObject.inword)
assert defstring in out
assert "Example: " in out or "No examples available" in out
assert err == ''
def test_random_word_exit():
testObject = randomDefinition('test')
testObject.word_list = []
with pytest.raises(SystemExit):
testObject.random_word()
def test_no_examples(capsys):
testObject = randomDefinition('test', showexample=True)
testObject.get_synset()
testObject.example = "NULLNULLNULL"
testObject.print_output()
out, err = capsys.readouterr()
assert "No examples available" in out
assert err == ''