~landscape/zope3/ztk-1.1.3

« back to all changes in this revision

Viewing changes to src/zope/testing/testrunner-progress.txt

  • Committer: Thomas Hervé
  • Date: 2009-09-21 06:45:37 UTC
  • mfrom: (7.1.2 newer-zope-testing)
  • Revision ID: thomas@canonical.com-20090921064537-zcfyuv32hxj9eah0
Merge newer-zope-testing [a=sidnei] [f=429702] [r=therve,free.ekayanaka]

Update zope.testing to 3.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Test Progress
2
 
=============
3
 
 
4
 
If the --progress (-p) option is used, progress information is printed and
5
 
a carriage return (rather than a new-line) is printed between
6
 
detail lines.  Let's look at the effect of --progress (-p) at different
7
 
levels of verbosity.
8
 
 
9
 
    >>> import os.path, sys
10
 
    >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
11
 
    >>> defaults = [
12
 
    ...     '--path', directory_with_tests,
13
 
    ...     '--tests-pattern', '^sampletestsf?$',
14
 
    ...     ]
15
 
 
16
 
    >>> sys.argv = 'test --layer 122 -p'.split()
17
 
    >>> from zope.testing import testrunner
18
 
    >>> testrunner.run(defaults)
19
 
    Running samplelayers.Layer122 tests:
20
 
      Set up samplelayers.Layer1 in 0.000 seconds.
21
 
      Set up samplelayers.Layer12 in 0.000 seconds.
22
 
      Set up samplelayers.Layer122 in 0.000 seconds.
23
 
      Running:
24
 
        1/34 (2.9%)\r
25
 
                   \r
26
 
        2/34 (5.9%)\r
27
 
                   \r
28
 
        3/34 (8.8%)\r
29
 
                   \r
30
 
        4/34 (11.8%)\r
31
 
                    \r
32
 
        5/34 (14.7%)\r
33
 
                    \r
34
 
        6/34 (17.6%)\r
35
 
                    \r
36
 
        7/34 (20.6%)\r
37
 
                    \r
38
 
        8/34 (23.5%)\r
39
 
                    \r
40
 
        9/34 (26.5%)\r
41
 
                    \r
42
 
        10/34 (29.4%)\r
43
 
                     \r
44
 
        11/34 (32.4%)\r
45
 
                     \r
46
 
        12/34 (35.3%)\r
47
 
                     \r
48
 
        17/34 (50.0%)\r
49
 
                     \r
50
 
        18/34 (52.9%)\r
51
 
                     \r
52
 
        19/34 (55.9%)\r
53
 
                     \r
54
 
        20/34 (58.8%)\r
55
 
                     \r
56
 
        21/34 (61.8%)\r
57
 
                     \r
58
 
        22/34 (64.7%)\r
59
 
                     \r
60
 
        23/34 (67.6%)\r
61
 
                     \r
62
 
        24/34 (70.6%)\r
63
 
                     \r
64
 
        25/34 (73.5%)\r
65
 
                     \r
66
 
        26/34 (76.5%)\r
67
 
                     \r
68
 
        27/34 (79.4%)\r
69
 
                     \r
70
 
        28/34 (82.4%)\r
71
 
                     \r
72
 
        29/34 (85.3%)\r
73
 
                     \r
74
 
        34/34 (100.0%)\r
75
 
                      \r
76
 
    <BLANKLINE>
77
 
      Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
78
 
    Tearing down left over layers:
79
 
      Tear down samplelayers.Layer122 in 0.000 seconds.
80
 
      Tear down samplelayers.Layer12 in 0.000 seconds.
81
 
      Tear down samplelayers.Layer1 in 0.000 seconds.
82
 
    False
83
 
 
84
 
(Note that, in the examples above and below, we show "\r" followed by
85
 
new lines where carriage returns would appear in actual output.)
86
 
 
87
 
Using a single level of verbosity causes test descriptions to be
88
 
output, but only if they fit in the terminal width.  The default
89
 
width, when the terminal width can't be determined, is 80:
90
 
 
91
 
>>> sys.argv = 'test --layer 122 -pv'.split()
92
 
>>> testrunner.run(defaults)
93
 
Running tests at level 1
94
 
Running samplelayers.Layer122 tests:
95
 
  Set up samplelayers.Layer1 in 0.000 seconds.
96
 
  Set up samplelayers.Layer12 in 0.000 seconds.
97
 
  Set up samplelayers.Layer122 in 0.000 seconds.
98
 
  Running:
99
 
    1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
100
 
                                                           \r
101
 
    2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
102
 
                                                           \r
103
 
    3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
104
 
                                                           \r
105
 
    4/34 (11.8%) test_x0 (sample1.sampletests.test122.TestB)\r
106
 
                                                            \r
107
 
    5/34 (14.7%) test_y1 (sample1.sampletests.test122.TestB)\r
108
 
                                                            \r
109
 
    6/34 (17.6%) test_z0 (sample1.sampletests.test122.TestB)\r
110
 
                                                            \r
111
 
    7/34 (20.6%) test_1 (sample1.sampletests.test122.TestNotMuch)\r
112
 
                                                                 \r
113
 
    8/34 (23.5%) test_2 (sample1.sampletests.test122.TestNotMuch)\r
114
 
                                                                 \r
115
 
    9/34 (26.5%) test_3 (sample1.sampletests.test122.TestNotMuch)\r
116
 
                                                                 \r
117
 
    10/34 (29.4%) test_x0 (sample1.sampletests.test122)\r
118
 
                                                       \r
119
 
    11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
120
 
                                                       \r
121
 
    12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
122
 
                                                       \r
123
 
    17/34 (50.0%) ... /testrunner-ex/sample1/sampletests/../../sampletestsl.txt\r
124
 
                                                                               \r
125
 
    18/34 (52.9%) test_x1 (sampletests.test122.TestA)\r
126
 
                                                     \r
127
 
    19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
128
 
                                                     \r
129
 
    20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
130
 
                                                     \r
131
 
    21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
132
 
                                                     \r
133
 
    22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
134
 
                                                     \r
135
 
    23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
136
 
                                                     \r
137
 
    24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
138
 
                                                          \r
139
 
    25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
140
 
                                                          \r
141
 
    26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
142
 
                                                          \r
143
 
    27/34 (79.4%) test_x0 (sampletests.test122)\r
144
 
                                               \r
145
 
    28/34 (82.4%) test_y0 (sampletests.test122)\r
146
 
                                               \r
147
 
    29/34 (85.3%) test_z1 (sampletests.test122)\r
148
 
                                               \r
149
 
    34/34 (100.0%) ... pe/testing/testrunner-ex/sampletests/../sampletestsl.txt\r
150
 
                                                                               \r
151
 
<BLANKLINE>
152
 
  Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
153
 
Tearing down left over layers:
154
 
  Tear down samplelayers.Layer122 in 0.000 seconds.
155
 
  Tear down samplelayers.Layer12 in 0.000 seconds.
156
 
  Tear down samplelayers.Layer1 in 0.000 seconds.
157
 
False
158
 
 
159
 
The terminal width is determined using the curses module.  To see
160
 
that, we'll provide a fake curses module:
161
 
 
162
 
    >>> class FakeCurses:
163
 
    ...     def setupterm(self):
164
 
    ...         pass
165
 
    ...     def tigetnum(self, ignored):
166
 
    ...         return 60
167
 
    >>> old_curses = sys.modules.get('curses')
168
 
    >>> sys.modules['curses'] = FakeCurses()
169
 
    >>> testrunner.run(defaults)
170
 
    Running tests at level 1
171
 
    Running samplelayers.Layer122 tests:
172
 
      Set up samplelayers.Layer1 in 0.000 seconds.
173
 
      Set up samplelayers.Layer12 in 0.000 seconds.
174
 
      Set up samplelayers.Layer122 in 0.000 seconds.
175
 
      Running:
176
 
        1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
177
 
                                                               \r
178
 
        2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
179
 
                                                               \r
180
 
        3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
181
 
                                                               \r
182
 
        4/34 (11.8%) test_x0 (...le1.sampletests.test122.TestB)\r
183
 
                                                               \r
184
 
        5/34 (14.7%) test_y1 (...le1.sampletests.test122.TestB)\r
185
 
                                                               \r
186
 
        6/34 (17.6%) test_z0 (...le1.sampletests.test122.TestB)\r
187
 
                                                               \r
188
 
        7/34 (20.6%) test_1 (...ampletests.test122.TestNotMuch)\r
189
 
                                                               \r
190
 
        8/34 (23.5%) test_2 (...ampletests.test122.TestNotMuch)\r
191
 
                                                               \r
192
 
        9/34 (26.5%) test_3 (...ampletests.test122.TestNotMuch)\r
193
 
                                                               \r
194
 
        10/34 (29.4%) test_x0 (sample1.sampletests.test122)\r
195
 
                                                           \r
196
 
        11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
197
 
                                                           \r
198
 
        12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
199
 
                                                           \r
200
 
        17/34 (50.0%) ... e1/sampletests/../../sampletestsl.txt\r
201
 
                                                               \r
202
 
        18/34 (52.9%) test_x1 (sampletests.test122.TestA)\r
203
 
                                                         \r
204
 
        19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
205
 
                                                         \r
206
 
        20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
207
 
                                                         \r
208
 
        21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
209
 
                                                         \r
210
 
        22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
211
 
                                                         \r
212
 
        23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
213
 
                                                         \r
214
 
        24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
215
 
                                                              \r
216
 
        25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
217
 
                                                              \r
218
 
        26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
219
 
                                                              \r
220
 
        27/34 (79.4%) test_x0 (sampletests.test122)\r
221
 
                                                   \r
222
 
        28/34 (82.4%) test_y0 (sampletests.test122)\r
223
 
                                                   \r
224
 
        29/34 (85.3%) test_z1 (sampletests.test122)\r
225
 
                                                   \r
226
 
        34/34 (100.0%) ... r-ex/sampletests/../sampletestsl.txt\r
227
 
                                                               \r
228
 
    <BLANKLINE>
229
 
      Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
230
 
    Tearing down left over layers:
231
 
      Tear down samplelayers.Layer122 in 0.000 seconds.
232
 
      Tear down samplelayers.Layer12 in 0.000 seconds.
233
 
      Tear down samplelayers.Layer1 in 0.000 seconds.
234
 
    False
235
 
 
236
 
    >>> sys.modules['curses'] = old_curses
237
 
 
238
 
If a second or third level of verbosity are added, we get additional
239
 
information.
240
 
 
241
 
    >>> sys.argv = 'test --layer 122 -pvv -t !txt'.split()
242
 
    >>> testrunner.run(defaults)
243
 
    Running tests at level 1
244
 
    Running samplelayers.Layer122 tests:
245
 
      Set up samplelayers.Layer1 in 0.000 seconds.
246
 
      Set up samplelayers.Layer12 in 0.000 seconds.
247
 
      Set up samplelayers.Layer122 in 0.000 seconds.
248
 
      Running:
249
 
        1/24 (4.2%) test_x1 (sample1.sampletests.test122.TestA)\r
250
 
                                                              \r
251
 
        2/24 (8.3%) test_y0 (sample1.sampletests.test122.TestA)\r
252
 
                                                              \r
253
 
        3/24 (12.5%) test_z0 (sample1.sampletests.test122.TestA)\r
254
 
                                                               \r
255
 
        4/24 (16.7%) test_x0 (sample1.sampletests.test122.TestB)\r
256
 
                                                               \r
257
 
        5/24 (20.8%) test_y1 (sample1.sampletests.test122.TestB)\r
258
 
                                                               \r
259
 
        6/24 (25.0%) test_z0 (sample1.sampletests.test122.TestB)\r
260
 
                                                               \r
261
 
        7/24 (29.2%) test_1 (sample1.sampletests.test122.TestNotMuch)\r
262
 
                                                                    \r
263
 
        8/24 (33.3%) test_2 (sample1.sampletests.test122.TestNotMuch)\r
264
 
                                                                    \r
265
 
        9/24 (37.5%) test_3 (sample1.sampletests.test122.TestNotMuch)\r
266
 
                                                                    \r
267
 
        10/24 (41.7%) test_x0 (sample1.sampletests.test122)\r
268
 
                                                          \r
269
 
        11/24 (45.8%) test_y0 (sample1.sampletests.test122)\r
270
 
                                                          \r
271
 
        12/24 (50.0%) test_z1 (sample1.sampletests.test122)\r
272
 
                                                          \r
273
 
        13/24 (54.2%) test_x1 (sampletests.test122.TestA)\r
274
 
                                                        \r
275
 
        14/24 (58.3%) test_y0 (sampletests.test122.TestA)\r
276
 
                                                        \r
277
 
        15/24 (62.5%) test_z0 (sampletests.test122.TestA)\r
278
 
                                                        \r
279
 
        16/24 (66.7%) test_x0 (sampletests.test122.TestB)\r
280
 
                                                        \r
281
 
        17/24 (70.8%) test_y1 (sampletests.test122.TestB)\r
282
 
                                                        \r
283
 
        18/24 (75.0%) test_z0 (sampletests.test122.TestB)\r
284
 
                                                        \r
285
 
        19/24 (79.2%) test_1 (sampletests.test122.TestNotMuch)\r
286
 
                                                             \r
287
 
        20/24 (83.3%) test_2 (sampletests.test122.TestNotMuch)\r
288
 
                                                             \r
289
 
        21/24 (87.5%) test_3 (sampletests.test122.TestNotMuch)\r
290
 
                                                             \r
291
 
        22/24 (91.7%) test_x0 (sampletests.test122)\r
292
 
                                                  \r
293
 
        23/24 (95.8%) test_y0 (sampletests.test122)\r
294
 
                                                  \r
295
 
        24/24 (100.0%) test_z1 (sampletests.test122)\r
296
 
                                                   \r
297
 
    <BLANKLINE>
298
 
      Ran 24 tests with 0 failures and 0 errors in 0.006 seconds.
299
 
    Tearing down left over layers:
300
 
      Tear down samplelayers.Layer122 in 0.000 seconds.
301
 
      Tear down samplelayers.Layer12 in 0.000 seconds.
302
 
      Tear down samplelayers.Layer1 in 0.000 seconds.
303
 
    False
304
 
 
305
 
Note that, in this example, we used a test-selection pattern starting
306
 
with '!' to exclude tests containing the string "txt".
307
 
 
308
 
    >>> sys.argv = 'test --layer 122 -pvvv -t!(txt|NotMuch)'.split()
309
 
    >>> testrunner.run(defaults)
310
 
    Running tests at level 1
311
 
    Running samplelayers.Layer122 tests:
312
 
      Set up samplelayers.Layer1 in 0.000 seconds.
313
 
      Set up samplelayers.Layer12 in 0.000 seconds.
314
 
      Set up samplelayers.Layer122 in 0.000 seconds.
315
 
      Running:
316
 
        1/18 (5.6%) test_x1 (sample1.sampletests.test122.TestA) (0.000 s)\r
317
 
                                                                          \r
318
 
        2/18 (11.1%) test_y0 (sample1.sampletests.test122.TestA) (0.000 s)\r
319
 
                                                                           \r
320
 
        3/18 (16.7%) test_z0 (sample1.sampletests.test122.TestA) (0.000 s)\r
321
 
                                                                           \r
322
 
        4/18 (22.2%) test_x0 (sample1.sampletests.test122.TestB) (0.000 s)\r
323
 
                                                                           \r
324
 
        5/18 (27.8%) test_y1 (sample1.sampletests.test122.TestB) (0.000 s)\r
325
 
                                                                           \r
326
 
        6/18 (33.3%) test_z0 (sample1.sampletests.test122.TestB) (0.000 s)\r
327
 
                                                                           \r
328
 
        7/18 (38.9%) test_x0 (sample1.sampletests.test122) (0.001 s)\r
329
 
                                                                     \r
330
 
        8/18 (44.4%) test_y0 (sample1.sampletests.test122) (0.001 s)\r
331
 
                                                                     \r
332
 
        9/18 (50.0%) test_z1 (sample1.sampletests.test122) (0.001 s)\r
333
 
                                                                     \r
334
 
        10/18 (55.6%) test_x1 (sampletests.test122.TestA) (0.000 s)\r
335
 
                                                                    \r
336
 
        11/18 (61.1%) test_y0 (sampletests.test122.TestA) (0.000 s)\r
337
 
                                                                    \r
338
 
        12/18 (66.7%) test_z0 (sampletests.test122.TestA) (0.000 s)\r
339
 
                                                                    \r
340
 
        13/18 (72.2%) test_x0 (sampletests.test122.TestB) (0.000 s)\r
341
 
                                                                    \r
342
 
        14/18 (77.8%) test_y1 (sampletests.test122.TestB) (0.000 s)\r
343
 
                                                                    \r
344
 
        15/18 (83.3%) test_z0 (sampletests.test122.TestB) (0.000 s)\r
345
 
                                                                    \r
346
 
        16/18 (88.9%) test_x0 (sampletests.test122) (0.001 s)\r
347
 
                                                              \r
348
 
        17/18 (94.4%) test_y0 (sampletests.test122) (0.001 s)\r
349
 
                                                              \r
350
 
        18/18 (100.0%) test_z1 (sampletests.test122) (0.001 s)\r
351
 
                                                               \r
352
 
    <BLANKLINE>
353
 
      Ran 18 tests with 0 failures and 0 errors in 0.006 seconds.
354
 
    Tearing down left over layers:
355
 
      Tear down samplelayers.Layer122 in 0.000 seconds.
356
 
      Tear down samplelayers.Layer12 in 0.000 seconds.
357
 
      Tear down samplelayers.Layer1 in 0.000 seconds.
358
 
    False
359
 
 
360
 
In this example, we also excluded tests with "NotMuch" in their names.
361
 
 
362
 
Unfortunately, the time data above doesn't buy us much because, in
363
 
practice, the line is cleared before there is time to see the
364
 
times. :/
365
 
 
366
 
 
367
 
Autodetecting progress
368
 
----------------------
369
 
 
370
 
The --auto-progress option will determine if stdout is a terminal, and only enable
371
 
progress output if so.
372
 
 
373
 
Let's pretend we have a terminal
374
 
 
375
 
    >>> class Terminal(object):
376
 
    ...     def __init__(self, stream):
377
 
    ...         self._stream = stream
378
 
    ...     def __getattr__(self, attr):
379
 
    ...         return getattr(self._stream, attr)
380
 
    ...     def isatty(self):
381
 
    ...         return True
382
 
    >>> real_stdout = sys.stdout
383
 
    >>> sys.stdout = Terminal(sys.stdout)
384
 
 
385
 
    >>> sys.argv = 'test -u -t test_one.TestNotMuch --auto-progress'.split()
386
 
    >>> testrunner.run(defaults)
387
 
    Running unit tests:
388
 
      Running:
389
 
        1/6 (16.7%)\r
390
 
                   \r
391
 
        2/6 (33.3%)\r
392
 
                   \r
393
 
        3/6 (50.0%)\r
394
 
                   \r
395
 
        4/6 (66.7%)\r
396
 
                   \r
397
 
        5/6 (83.3%)\r
398
 
                   \r
399
 
        6/6 (100.0%)\r
400
 
                    \r
401
 
    <BLANKLINE>
402
 
      Ran 6 tests with 0 failures and 0 errors in 0.000 seconds.
403
 
    False
404
 
 
405
 
Let's stop pretending
406
 
 
407
 
    >>> sys.stdout = real_stdout
408
 
 
409
 
    >>> sys.argv = 'test -u -t test_one.TestNotMuch --auto-progress'.split()
410
 
    >>> testrunner.run(defaults)
411
 
    Running unit tests:
412
 
      Ran 6 tests with 0 failures and 0 errors in 0.000 seconds.
413
 
    False
414
 
 
415
 
 
416
 
Disabling progress indication
417
 
-----------------------------
418
 
 
419
 
If -p or --progress have been previously provided on the command line (perhaps by a
420
 
wrapper script) but you do not desire progress indication, you can switch it off with
421
 
--no-progress:
422
 
 
423
 
    >>> sys.argv = 'test -u -t test_one.TestNotMuch -p --no-progress'.split()
424
 
    >>> testrunner.run(defaults)
425
 
    Running unit tests:
426
 
      Ran 6 tests with 0 failures and 0 errors in 0.000 seconds.
427
 
    False
428