forked from kyclark/tiny_python_projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·87 lines (61 loc) · 1.98 KB
/
test.py
File metadata and controls
executable file
·87 lines (61 loc) · 1.98 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
"""tests for classify.py"""
import os
import random
import re
import string
from subprocess import getstatusoutput
prg = './classify.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# --------------------------------------------------
def test_usage():
"""usage"""
for flag in ['-h', '--help']:
rv, out = getstatusoutput(f'{prg} {flag}')
assert rv == 0
assert out.lower().startswith('usage')
# --------------------------------------------------
def test_upper():
"""upper"""
word = random.choice('APPLE BANANA CHERRY'.split())
rv, out = getstatusoutput(f'{prg} {word}')
assert rv == 0
assert out == f'{word} is uppercase.'
# --------------------------------------------------
def test_lower():
"""lower"""
word = random.choice('apple banana cherry'.split())
rv, out = getstatusoutput(f'{prg} {word}')
assert rv == 0
assert out == f'{word} is lowercase.'
# --------------------------------------------------
def test_title():
"""title"""
word = random.choice('Apple Banana Cherry'.split())
rv, out = getstatusoutput(f'{prg} {word}')
assert rv == 0
assert out == f'{word} is title case.'
# --------------------------------------------------
def test_digit():
"""digit"""
word = random.choice('1 2 3'.split())
rv, out = getstatusoutput(f'{prg} {word}')
assert rv == 0
assert out == f'{word} is a digit.'
# --------------------------------------------------
def test_space():
"""space"""
word = random.choice([' ', '\t'])
rv, out = getstatusoutput(f'{prg} "{word}"')
assert rv == 0
assert out == f'input is space.'
# --------------------------------------------------
def test_unclassified():
"""unclassified"""
word = random.choice('1.2 3.04 40.5'.split())
rv, out = getstatusoutput(f'{prg} "{word}"')
assert rv == 0
assert out == f'{word} is unclassified.'