@@ -39,6 +39,7 @@ Test command line utilities and applications by whitelisting them with app-speci
39
39
>> > tester = Runner()
40
40
>> > tester.call_engines[' echo' ] = SubprocessValidator()
41
41
>> > tester.teststring(test_str)
42
+ # echo 'Pining for the fjords'
42
43
43
44
Click applications
44
45
~~~~~~~~~~~~~~~~~~
@@ -66,6 +67,7 @@ This can now be tested in docstrings:
66
67
...
67
68
... $ hello Polly Parrot
68
69
... Usage: hello [OPTIONS] NAME
70
+ ... Try "hello --help" for help.
69
71
... <BLANKLINE>
70
72
... Error: Got unexpected extra argument (Parrot)
71
73
...
@@ -83,6 +85,9 @@ Click applications can be tested with a ``ClickValidator`` engine:
83
85
>> > tester.call_engines[' hello' ] = ClickValidator(hello)
84
86
85
87
>> > tester.teststring(test_str)
88
+ # hello Polly
89
+ # hello Polly Parrot
90
+ # hello 'Polly Parrot'
86
91
87
92
88
93
Mixed applications
@@ -120,6 +125,10 @@ Your app can be combined with other command-line utilities by adding multiple en
120
125
>> > tester.call_engines[' cat' ] = SubprocessValidator()
121
126
122
127
>> > tester.teststring(test_str)
128
+ # hello Polly
129
+ # echo 'Pining for the fjords'
130
+ # python -c "with open('tmp.txt', 'w+') as f: f.write('Pushing up daisies')"
131
+ # cat tmp.txt
123
132
124
133
Suppressing commands
125
134
~~~~~~~~~~~~~~~~~~~~
@@ -131,14 +140,15 @@ Commands can be skipped altogether with a ``SkipValidator``:
131
140
>> > test_str = '''
132
141
... .. code-block:: bash
133
142
...
134
- ... $ aws storage buckets list
143
+ ... $ aws storage buckets list --password $MY_PASSWORD
135
144
...
136
145
... '''
137
146
138
147
>> > from bashdoctest.validators import SkipValidator
139
148
>> > tester.call_engines[' aws' ] = SkipValidator()
140
149
141
150
>> > tester.teststring(test_str)
151
+ # aws storage ...
142
152
143
153
144
154
Illegal commands
@@ -190,6 +200,7 @@ Unrecognized commands will not raise an error if +SKIP is specified
190
200
...
191
201
... '''
192
202
>> > tester.teststring(test_str)
203
+ # nmake all
193
204
194
205
Error handling
195
206
~~~~~~~~~~~~~~
@@ -212,10 +223,9 @@ Lines failing to match the command's output will raise an error
212
223
>> > tester.teststring(test_str) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
213
224
Traceback (most recent call last):
214
225
...
215
- ValueError : bashdoctest test failed. There, it moved!
216
- != " No it didn't!"
217
- + There, it moved!
218
- - " No it didn't!"
226
+ ValueError : Differences (ndiff with - expected + actual):
227
+ - " No it didn't!"
228
+ + There, it moved!
219
229
220
230
Known issues
221
231
------------
@@ -245,10 +255,9 @@ All arguments to commands are passed as arguments to the first command. Therefor
245
255
>> > tester.teststring(test_str) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
246
256
Traceback (most recent call last):
247
257
...
248
- ValueError : bashhdoctest test failed. hello > test.txt
249
- !=
250
- + hello > test.txt
251
- -
258
+ ValueError : Differences (ndiff with - expected + actual):
259
+ + hello > test.txt
260
+ < BLANKLINE >
252
261
253
262
254
263
0 commit comments