|
1 | | -# Howler |
2 | | - |
3 | | -https://www.youtube.com/playlist?list=PLhOuww6rJJNNzo5zqtx0388myQkUKyrQz |
4 | | - |
5 | | -Write a program that uppercases the given text: |
6 | | - |
7 | | -``` |
8 | | -$ ./howler.py 'The quick brown fox jumps over the lazy dog.' |
9 | | -THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. |
10 | | -``` |
11 | | - |
12 | | -If the text names a file, uppercase the contents of the file: |
13 | | - |
14 | | -``` |
15 | | -$ ./howler.py ../inputs/fox.txt |
16 | | -THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. |
17 | | -``` |
18 | | - |
19 | | -If given no arguments, print a brief usage: |
20 | | - |
21 | | -``` |
22 | | -$ ./howler.py |
23 | | -usage: howler.py [-h] [-o str] str |
24 | | -howler.py: error: the following arguments are required: str |
25 | | -``` |
26 | | - |
27 | | -If the `-o` or `--outfile` option is present, write the output to the given file and print nothing: |
28 | | - |
29 | | -``` |
30 | | -$ ./howler.py ../inputs/fox.txt -o out.txt |
31 | | -``` |
32 | | - |
33 | | -There should now be an `out.txt` file with the contents: |
34 | | - |
35 | | -``` |
36 | | -$ cat out.txt |
37 | | -THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. |
38 | | -``` |
39 | | - |
40 | | -Respond to `-h` or `--help` with a longer usage: |
41 | | - |
42 | | -``` |
43 | | -$ ./howler.py -h |
44 | | -usage: howler.py [-h] [-o str] str |
45 | | -
|
46 | | -Howler (upper-cases input) |
47 | | -
|
48 | | -positional arguments: |
49 | | - str Input string or file |
50 | | -
|
51 | | -optional arguments: |
52 | | - -h, --help show this help message and exit |
53 | | - -o str, --outfile str |
54 | | - Output filename (default: ) |
55 | | -``` |
56 | | - |
57 | | -Run the test suite to ensure your program is working correctly: |
58 | | - |
59 | | -``` |
60 | | -$ make test |
61 | | -pytest -xv test.py |
62 | | -============================= test session starts ============================== |
63 | | -... |
64 | | -collected 5 items |
65 | | -
|
66 | | -test.py::test_exists PASSED [ 20%] |
67 | | -test.py::test_usage PASSED [ 40%] |
68 | | -test.py::test_text_stdout PASSED [ 60%] |
69 | | -test.py::test_text_outfile PASSED [ 80%] |
70 | | -test.py::test_file PASSED [100%] |
71 | | -
|
72 | | -============================== 5 passed in 0.40s =============================== |
73 | | -``` |
0 commit comments