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
·75 lines (49 loc) · 1.75 KB
/
Copy pathtest.py
File metadata and controls
executable file
·75 lines (49 loc) · 1.75 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
#!/usr/bin/env python3
"""tests for apples.py"""
import re
import os
from subprocess import getstatusoutput, getoutput
prg = './apples.py'
fox = '../inputs/fox.txt'
# --------------------------------------------------
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 re.match("usage", out, re.IGNORECASE)
# --------------------------------------------------
def test_bad_vowel():
"""Should fail on a bad vowel"""
rv, out = getstatusoutput(f'{prg} -v x foo')
assert rv != 0
assert re.match("usage", out, re.IGNORECASE)
# --------------------------------------------------
def test_command_line():
""" foo -> faa """
out = getoutput(f'{prg} foo')
assert out.strip() == 'faa'
# --------------------------------------------------
def test_command_line_with_vowel():
""" foo -> fii """
out = getoutput(f'{prg} -v i foo')
assert out.strip() == 'fii'
# --------------------------------------------------
def test_command_line_with_vowel_preserve_case():
""" foo -> fii """
out = getoutput(f'{prg} "APPLES AND BANANAS" --vowel i')
assert out.strip() == 'IPPLIS IND BININIS'
# --------------------------------------------------
def test_file():
""" fox.txt """
out = getoutput(f'{prg} {fox}')
assert out.strip() == 'Tha qaack brawn fax jamps avar tha lazy dag.'
# --------------------------------------------------
def test_file_with_vowel():
""" fox.txt """
out = getoutput(f'{prg} --vowel o {fox}')
assert out.strip() == 'Tho qoock brown fox jomps ovor tho lozy dog.'