This file is indexed.

/usr/lib/python2.7/dist-packages/zope.testrunner-4.4.2.egg-info/PKG-INFO is in python-zope.testrunner 4.4.2-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
Metadata-Version: 1.1
Name: zope.testrunner
Version: 4.4.2
Summary: Zope testrunner script.
Home-page: http://pypi.python.org/pypi/zope.testrunner
Author: Zope Foundation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: ***************
        zope.testrunner
        ***************
        
        |buildstatus|_
        |winbotstatus|_
        
        .. contents::
        
        This package provides a flexible test runner with layer support.
        
        You can find more `detailed documentation`_ on PyPI or in the ``src/``
        directory.
        
        
        Getting started
        ***************
        
        Buildout-based projects
        =======================
        
        zope.testrunner is often used for projects that use buildout_::
        
            [buildout]
            develop = .
            parts = ... test ...
        
            [test]
            recipe = zc.recipe.testrunner
            eggs = mypackage
        
        The usual buildout process ::
        
            python bootstrap.py
            bin/buildout
        
        creates a ``bin/test`` script that will run the tests for *mypackage*.
        
        .. tip::
        
            zc.recipe.testrunner_ takes care to specify the right
            ``--test-path`` option in the generated script.  You can add
            other options (such as ``--tests-pattern``) too; check
            zc.recipe.testrunner_'s documentation for details.
        
        
        Virtualenv-based projects
        =========================
        
        ``pip install zope.testrunner`` and you'll get a ``zope-testrunner``
        script.  Run your tests with ::
        
            zope-testrunner --test-path=path/to/your/source/tree
        
        Your source code needs to be available for the testrunner to import,
        so you need to run ``python setup.py install`` or ``pip install -e
        .`` into the same virtualenv_.
        
        
        Some useful command-line options to get you started
        ===================================================
        
        -p              show a percentage indicator
        -v              increase verbosity
        -c              colorize the output
        -t test         specify test names (one or more regexes)
        -m module       specify test modules (one or more regexes)
        -s package      specify test packages (one or more regexes)
        --list-tests    show names of tests instead of running them
        -x              stop on first error or failure
        -D, --pdb       enable post-mortem debugging of test failures
        --help          show *all* command-line options (there are many more!)
        
        For example ::
        
            bin/test -pvc -m test_foo -t TestBar
        
        runs all TestBar tests from a module called test_foo.py.
        
        
        Writing tests
        =============
        
        ``zope.testrunner`` expects to find your tests inside your package
        directory, in a subpackage or module named ``tests``.  Test modules
        in a test subpackage should be named ``test*.py``.
        
        .. tip::
        
            You can change these assumptions with ``--tests-pattern`` and
            ``--test-file-pattern`` test runner options.
        
        Tests themselves should be classes inheriting from
        ``unittest.TestCase``, and if you wish to use doctests, please tell
        the test runner where to find them and what options to use for them
        in by supplying a function named ``test_suite``.
        
        Example::
        
            import unittest
            import doctest
        
            class TestArithmetic(unittest.TestCase):
        
                def test_two_plus_two(self):
                    self.assertEqual(2 + 2, 4)
        
        
            def doctest_string_formatting():
                """Test Python string formatting
        
                    >>> print('{} + {}'.format(2, 2))
                    2 + 2
        
                """
        
            def test_suite():
                return unittest.TestSuite([
                    unittest.makeSuite(TestArithmetic),
                    doctest.DocTestSuite(),
                    doctest.DocFileSuite('../README.txt',
                                         optionflags=doctest.ELLIPSIS),
                ])
        
        
        Test grouping
        =============
        
        In addition to per-package and per-module filtering, zope.testrunner
        has other mechanisms for grouping tests:
        
        * **layers** allow you to have shared setup/teardown code to be used
          by a group of tests, that is executed only once, and not for each
          test.  Layers are orthogonal to the usual package/module structure
          and are specified by setting the ``layer`` attribute on test
          suites.
        
        * **levels** allow you to group slow-running tests and not run them
          by default.  They're specified by setting the ``level`` attribute
          on test suites to an int.
        
        For more details please see the `detailed documentation`_.
        
        
        Other features
        ==============
        
        zope.testrunner can profile your tests, measure test coverage,
        check for memory leaks, integrate with subunit_, shuffle the
        test execution order, and run multiple tests in parallel.
        
        For more details please see the `detailed documentation`_.
        
        .. _buildout: http://www.buildout.org/
        .. _virtualenv: http://www.virtualenv.org/
        .. _zc.recipe.testrunner: http://pypi.python.org/pypi/zc.recipe.testrunner
        .. _subunit: http://pypi.python.org/pypi/subunit
        .. _detailed documentation: http://docs.zope.org/zope.testrunner/
        
        .. |buildstatus| image:: https://api.travis-ci.org/zopefoundation/zope.testrunner.png?branch=master
        .. _buildstatus: https://travis-ci.org/zopefoundation/zope.testrunner
        
        .. |winbotstatus| image:: http://winbot.zope.org/buildstatusimage?builder=zope.testrunner_py_265_32&number=-1
        .. _winbotstatus: http://winbot.zope.org/builders/zope.testrunner_py_265_32/builds/-1
        
        zope.testrunner Changelog
        *************************
        
        4.4.2 (2014-02-22)
        ==================
        
        - Drop support for Python 3.1.
        
        - Fix post-mortem debugging when a non-printable exception happens
          (https://github.com/zopefoundation/zope.testrunner/issues/8).
        
        
        4.4.1 (2013-07-10)
        ==================
        
        - Updated ``boostrap.py`` to version 2.2.
        
        - Fix nondeterministic test failures on Python 3.3
        
        - Tear down layers after ``post_mortem`` debugging is finished.
        
        - Fix tests that write to source directory, it might be read-only.
        
        
        4.4.0 (2013-06-06)
        ==================
        
        - Fix tests selection when the negative "!" pattern is used several times
          (LP #1160965)
        
        - Moved tests into a 'tests' subpackage.
        
        - Made ``python -m zope.testrunner`` work again.
        
        - Support 'skip' feature of unittest2 (which became the new unittest in Python
          2.7).
        
        - Better diagnostics when communication with subprocess fails
          (https://github.com/zopefoundation/zope.testrunner/issues/5).
        
        - Do not break subprocess execution when the test suite changes the working
          directory (https://github.com/zopefoundation/zope.testrunner/issues/6).
        
        - Count test module import errors as errors (LP #1026576).
        
        
        4.3.3 (2013-03-03)
        ==================
        
        - Running layers in sub-processes did not use to work when run via
          ``python setup.py ftest`` since it tried to run setup.py with all the
          command line options. It now detects ``setup.py`` runs and we run the test
          runner directly.
        
        
        4.3.2 (2013-03-03)
        ==================
        
        - Fix ``SkipLayers`` class in cases where the distribution specifies a
          ``test_suite`` value.
        
        
        4.3.1 (2013-03-02)
        ==================
        
        - Fixed a bug in the `ftest` command and added a test.
        
        - Fixed a trivial test failure with Python 3 of the previous release.
        
        
        4.3.0 (2013-03-02)
        ==================
        
        - Expose `ftest` distutils command via an entry point.
        
        - Added tests for ``zope.testrunner.eggsupport``.
        
        
        4.2.0 (2013-02-12)
        ==================
        
        - Dropped use of 2to3, rewrote source code to be compatible with all Python
          versions.  Introduced a dependency on `six`_.
        
        
        4.1.1 (2013-02-08)
        ==================
        
        - Dropped use of zope.fixers (LP: #1118877).
        
        - Fixed tox test error reporting; fixed tests on Pythons 2.6, 3.1, 3.2, 3.3 and
          PyPy 1.9.
        
        - Fix --shuffle ordering on Python 3.2 to be the same as it was on older Python
          versions.
        
        - Fix --shuffle nondeterminism when multiple test layers are present.
          Note: this will likely change the order of tests for the same --shuffle-seed.
        
        - New option: --profile-directory.  Use it in the test suite so that tests
          executed by detox in parallel don't conflict.
        
        - Use a temporary coverage directory in the test suite so that tests
          executed by detox in parallel don't conflict.
        
        - Fix --post-mortem (aka -D, --pdb) when a test module cannot be imported
          or is invalid (LP #1119363).
        
        
        4.1.0 (2013-02-07)
        ==================
        
        - Replaced deprecated ``zope.interface.implements`` usage with equivalent
          ``zope.interface.implementer`` decorator.
        
        - Dropped support for Python 2.4 and 2.5.
        
        - Made StartUpFailure compatible with unittest.TextTestRunner() (LP #1118344).
        
        
        4.0.4 (2011-10-25)
        ==================
        
        - Work around sporadic timing-related issues in the subprocess buffering
          tests.  Thanks to Jonathan Ballet for the patch!
        
        
        4.0.3 (2011-03-17)
        ==================
        
        - Added back support for Python <= 2.6 which was broken in 4.0.2.
        
        
        4.0.2 (2011-03-16)
        ==================
        
        - Added back Python 3 support which was broken in 4.0.1.
        
        - Fixed `Unexpected success`_ support by implementing the whole concept.
        
        - Added support for the new __pycache__ directories in Python 3.2.
        
        
        4.0.1 (2011-02-21)
        ==================
        
        - LP #719369: An `Unexpected success`_ (concept introduced in Python 2.7) is
          no longer handled as success but as failure. This is a workaround. The
          whole unexpected success concept might be implemented later.
        
        .. _`Unexpected success`: http://www.voidspace.org.uk/python/articles/unittest2.shtml#more-skipping
        
        
        4.0.0 (2010-10-19)
        ==================
        
        - Show more information about layers whose setup fails (LP #638153).
        
        
        4.0.0b5 (2010-07-20)
        ====================
        
        - Update fix for LP #221151 to a spelling compatible with Python 2.4.
        
        - Timestamps are now always included in subunit output (r114849).
        
        - LP #591309: fix a crash when subunit reports test failures containing
          UTF8-encoded data.
        
        
        4.0.0b4 (2010-06-23)
        ====================
        
        - Package as a zipfile to work around Python 2.4 distutils bug (no
          feature changes or bugfixes in ``zope.testrunner`` itself).
        
        
        4.0.0b3 (2010-06-16)
        ====================
        
        - LP #221151: keep ``unittest.TestCase.shortDescription`` happy by supplying
          a ``_testMethodDoc`` attribute.
        
        - LP #595052: keep the distribution installable under Python 2.4:  its
          distutils appears to munge the empty ``__init__.py`` file in the
          ``foo.bar`` egg used for testing into a directory.
        
        - LP #580083: fix the ``bin/test`` script to run only tests from
          ``zope.testrunner``.
        
        - LP #579019: When layers were run in parallel, their tearDown was
          not called. Additionally, the first layer which was run in the main
          thread did not have its tearDown called either.
        
        
        4.0.0b2 (2010-05-03)
        ====================
        
        - Having 'sampletests' in the MANIFEST.in gave warnings, but doesn't actually
          seem to include any more files, so I removed it.
        
        - Moved zope.testing.exceptions to zope.testrunner.exceptions. Now
          zope.testrunner no longer requires zope.testing except for when running
          its own tests.
        
        
        4.0.0b1 (2010-04-29)
        ====================
        
        - Initial release of the testrunner from zope.testrunner as its own module.
        
        
        .. _six: http://pypi.python.org/pypi/six
        
        Detailed Documentation
        **********************
        
        Test Runner
        ===========
        
        The testrunner module is used to run automated tests defined using the
        unittest framework.  Its primary feature is that it *finds* tests by
        searching directory trees.  It doesn't require the manual
        concatenation of specific test suites.  It is highly customizable and
        should be usable with any project.  In addition to finding and running
        tests, it provides the following additional features:
        
        - Test filtering using specifications of:
        
          o test packages within a larger tree
        
          o regular expression patterns for test modules
        
          o regular expression patterns for individual tests
        
        - Organization of tests into levels and layers
        
          Sometimes, tests take so long to run that you don't want to run them
          on every run of the test runner.  Tests can be defined at different
          levels.  The test runner can be configured to only run tests at a
          specific level or below by default.  Command-line options can be
          used to specify a minimum level to use for a specific run, or to run
          all tests.  Individual tests or test suites can specify their level
          via a 'level' attribute. where levels are integers increasing from 1.
        
          Most tests are unit tests.  They don't depend on other facilities, or
          set up whatever dependencies they have.  For larger applications,
          it's useful to specify common facilities that a large number of
          tests share.  Making each test set up and and tear down these
          facilities is both ineffecient and inconvenient.  For this reason,
          we've introduced the concept of layers, based on the idea of layered
          application architectures.  Software build for a layer should be
          able to depend on the facilities of lower layers already being set
          up.  For example, Zope defines a component architecture.  Much Zope
          software depends on that architecture.  We should be able to treat
          the component architecture as a layer that we set up once and reuse.
          Similarly, Zope application software should be able to depend on the
          Zope application server without having to set it up in each test.
        
          The test runner introduces test layers, which are objects that can
          set up environments for tests within the layers to use.  A layer is
          set up before running the tests in it.  Individual tests or test
          suites can define a layer by defining a `layer` attribute, which is
          a test layer.
        
        - Reporting
        
          - progress meter
        
          - summaries of tests run
        
        - Analysis of test execution
        
          - post-mortem debugging of test failures
        
          - memory leaks
        
          - code coverage
        
          - source analysis using pychecker
        
          - memory errors
        
          - execution times
        
          - profiling
        
        Simple Usage
        ============
        
        The test runner consists of an importable module.  The test runner is
        used by providing scripts that import and invoke the `run` method from
        the module.  The `testrunner` module is controlled via command-line
        options.  Test scripts supply base and default options by supplying a
        list of default command-line options that are processed before the
        user-supplied command-line options are provided.
        
        Typically, a test script does 2 things:
        
        - Adds the directory containing the zope package to the Python
          path.
        
        - Calls the test runner with default arguments and arguments supplied
          to the script.
        
          Normally, it just passes default/setup arguments.  The test runner
          uses `sys.argv` to get the user's input.
        
        This testrunner_ex subdirectory contains a number of sample packages
        with tests.  Let's run the tests found here. First though, we'll set
        up our default options:
        
            >>> import os.path
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
        The default options are used by a script to customize the test runner
        for a particular application.  In this case, we use two options:
        
        path
          Set the path where the test runner should look for tests.  This path
          is also added to the Python path.
        
        tests-pattern
          Tell the test runner how to recognize modules or packages containing
          tests.
        
        Now, if we run the tests, without any other options:
        
            >>> from zope import testrunner
            >>> import sys
            >>> sys.argv = ['test']
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer11 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer111 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer112 tests:
              Tear down samplelayers.Layer111 in N.NNN seconds.
              Set up samplelayers.Layer112 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer121 tests:
              Set up samplelayers.Layer121 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer122 tests:
              Tear down samplelayers.Layer121 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 321 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        we see the normal testrunner output, which summarizes the tests run for
        each layer.  For each layer, we see what layers had to be torn down or
        set up to run the layer and we see the number of tests run, with
        results.
        
        The test runner returns a boolean indicating whether there were
        errors.  In this example, there were no errors, so it returned False.
        
        (Of course, the times shown in these examples are just examples.
        Times will vary depending on system speed.)
        
        Layers
        ======
        
        A Layer is an object providing setup and teardown methods used to setup
        and teardown the environment provided by the layer. It may also provide
        setup and teardown methods used to reset the environment provided by the
        layer between each test.
        
        Layers are generally implemented as classes using class methods.
        
        >>> class BaseLayer:
        ...     def setUp(cls):
        ...         log('BaseLayer.setUp')
        ...     setUp = classmethod(setUp)
        ...
        ...     def tearDown(cls):
        ...         log('BaseLayer.tearDown')
        ...     tearDown = classmethod(tearDown)
        ...
        ...     def testSetUp(cls):
        ...         log('BaseLayer.testSetUp')
        ...     testSetUp = classmethod(testSetUp)
        ...
        ...     def testTearDown(cls):
        ...         log('BaseLayer.testTearDown')
        ...     testTearDown = classmethod(testTearDown)
        ...
        
        Layers can extend other layers. Note that they do not explicitly
        invoke the setup and teardown methods of other layers - the test runner
        does this for us in order to minimize the number of invocations.
        
        >>> class TopLayer(BaseLayer):
        ...     def setUp(cls):
        ...         log('TopLayer.setUp')
        ...     setUp = classmethod(setUp)
        ...
        ...     def tearDown(cls):
        ...         log('TopLayer.tearDown')
        ...     tearDown = classmethod(tearDown)
        ...
        ...     def testSetUp(cls):
        ...         log('TopLayer.testSetUp')
        ...     testSetUp = classmethod(testSetUp)
        ...
        ...     def testTearDown(cls):
        ...         log('TopLayer.testTearDown')
        ...     testTearDown = classmethod(testTearDown)
        ...
        
        Tests or test suites specify what layer they need by storing a reference
        in the 'layer' attribute.
        
        >>> import unittest
        >>> class TestSpecifyingBaseLayer(unittest.TestCase):
        ...     'This TestCase explicitly specifies its layer'
        ...     layer = BaseLayer
        ...     name = 'TestSpecifyingBaseLayer' # For testing only
        ...
        ...     def setUp(self):
        ...         log('TestSpecifyingBaseLayer.setUp')
        ...
        ...     def tearDown(self):
        ...         log('TestSpecifyingBaseLayer.tearDown')
        ...
        ...     def test1(self):
        ...         log('TestSpecifyingBaseLayer.test1')
        ...
        ...     def test2(self):
        ...         log('TestSpecifyingBaseLayer.test2')
        ...
        >>> class TestSpecifyingNoLayer(unittest.TestCase):
        ...     'This TestCase specifies no layer'
        ...     name = 'TestSpecifyingNoLayer' # For testing only
        ...     def setUp(self):
        ...         log('TestSpecifyingNoLayer.setUp')
        ...
        ...     def tearDown(self):
        ...         log('TestSpecifyingNoLayer.tearDown')
        ...
        ...     def test1(self):
        ...         log('TestSpecifyingNoLayer.test')
        ...
        ...     def test2(self):
        ...         log('TestSpecifyingNoLayer.test')
        ...
        
        Create a TestSuite containing two test suites, one for each of
        TestSpecifyingBaseLayer and TestSpecifyingNoLayer.
        
        >>> umbrella_suite = unittest.TestSuite()
        >>> umbrella_suite.addTest(unittest.makeSuite(TestSpecifyingBaseLayer))
        >>> no_layer_suite = unittest.makeSuite(TestSpecifyingNoLayer)
        >>> umbrella_suite.addTest(no_layer_suite)
        
        Before we can run the tests, we need to setup some helpers.
        
        >>> from zope.testrunner import options
        >>> from zope.testing.loggingsupport import InstalledHandler
        >>> import logging
        >>> log_handler = InstalledHandler('zope.testrunner.tests')
        >>> def log(msg):
        ...     logging.getLogger('zope.testrunner.tests').info(msg)
        >>> def fresh_options():
        ...     opts = options.get_options(['--test-filter', '.*'])
        ...     opts.resume_layer = None
        ...     opts.resume_number = 0
        ...     return opts
        
        Now we run the tests. Note that the BaseLayer was not setup when
        the TestSpecifyingNoLayer was run and setup/torn down around the
        TestSpecifyingBaseLayer tests.
        
        >>> from zope.testrunner.runner import Runner
        >>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
        >>> succeeded = runner.run()
        Running ...BaseLayer tests:
          Set up ...BaseLayer in N.NNN seconds.
          Ran 2 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Running zope.testrunner.layer.UnitTests tests:
          Tear down ...BaseLayer in N.NNN seconds.
          Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
          Ran 2 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Tearing down left over layers:
          Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        Total: 4 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        
        
        Now lets specify a layer in the suite containing TestSpecifyingNoLayer
        and run the tests again. This demonstrates the other method of specifying
        a layer. This is generally how you specify what layer doctests need.
        
        >>> no_layer_suite.layer = BaseLayer
        >>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
        >>> succeeded = runner.run()
        Running ...BaseLayer tests:
          Set up ...BaseLayer in N.NNN seconds.
          Ran 4 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Tearing down left over layers:
          Tear down ...BaseLayer in N.NNN seconds.
        
        Clear our logged output, as we want to inspect it shortly.
        
        >>> log_handler.clear()
        
        Now lets also specify a layer in the TestSpecifyingNoLayer class and rerun
        the tests. This demonstrates that the most specific layer is used. It also
        shows the behavior of nested layers - because TopLayer extends BaseLayer,
        both the BaseLayer and TopLayer environments are setup when the
        TestSpecifyingNoLayer tests are run.
        
        >>> TestSpecifyingNoLayer.layer = TopLayer
        >>> runner = Runner(options=fresh_options(), args=[], found_suites=[umbrella_suite])
        >>> succeeded = runner.run()
        Running ...BaseLayer tests:
          Set up ...BaseLayer in N.NNN seconds.
          Ran 2 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Running ...TopLayer tests:
          Set up ...TopLayer in N.NNN seconds.
          Ran 2 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Tearing down left over layers:
          Tear down ...TopLayer in N.NNN seconds.
          Tear down ...BaseLayer in N.NNN seconds.
        Total: 4 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        
        
        If we inspect our trace of what methods got called in what order, we can
        see that the layer setup and teardown methods only got called once. We can
        also see that the layer's test setup and teardown methods got called for
        each test using that layer in the right order.
        
        >>> def report():
        ...     print("Report:")
        ...     for record in log_handler.records:
        ...         print(record.getMessage())
        >>> report()
        Report:
        BaseLayer.setUp
        BaseLayer.testSetUp
        TestSpecifyingBaseLayer.setUp
        TestSpecifyingBaseLayer.test1
        TestSpecifyingBaseLayer.tearDown
        BaseLayer.testTearDown
        BaseLayer.testSetUp
        TestSpecifyingBaseLayer.setUp
        TestSpecifyingBaseLayer.test2
        TestSpecifyingBaseLayer.tearDown
        BaseLayer.testTearDown
        TopLayer.setUp
        BaseLayer.testSetUp
        TopLayer.testSetUp
        TestSpecifyingNoLayer.setUp
        TestSpecifyingNoLayer.test
        TestSpecifyingNoLayer.tearDown
        TopLayer.testTearDown
        BaseLayer.testTearDown
        BaseLayer.testSetUp
        TopLayer.testSetUp
        TestSpecifyingNoLayer.setUp
        TestSpecifyingNoLayer.test
        TestSpecifyingNoLayer.tearDown
        TopLayer.testTearDown
        BaseLayer.testTearDown
        TopLayer.tearDown
        BaseLayer.tearDown
        
        Now lets stack a few more layers to ensure that our setUp and tearDown
        methods are called in the correct order.
        
        >>> from zope.testrunner.find import name_from_layer
        >>> class A(object):
        ...     def setUp(cls):
        ...         log('%s.setUp' % name_from_layer(cls))
        ...     setUp = classmethod(setUp)
        ...
        ...     def tearDown(cls):
        ...         log('%s.tearDown' % name_from_layer(cls))
        ...     tearDown = classmethod(tearDown)
        ...
        ...     def testSetUp(cls):
        ...         log('%s.testSetUp' % name_from_layer(cls))
        ...     testSetUp = classmethod(testSetUp)
        ...
        ...     def testTearDown(cls):
        ...         log('%s.testTearDown' % name_from_layer(cls))
        ...     testTearDown = classmethod(testTearDown)
        ...         
        >>> class B(A): pass
        >>> class C(B): pass
        >>> class D(A): pass
        >>> class E(D): pass
        >>> class F(C,E): pass
        
        >>> class DeepTest(unittest.TestCase):
        ...     layer = F
        ...     def test(self):
        ...         pass
        >>> suite = unittest.makeSuite(DeepTest)
        >>> log_handler.clear()
        >>> runner = Runner(options=fresh_options(), args=[], found_suites=[suite])
        >>> succeeded = runner.run() #doctest: +ELLIPSIS
        Running ...F tests:
          Set up ...A in N.NNN seconds.
          Set up ...B in N.NNN seconds.
          Set up ...C in N.NNN seconds.
          Set up ...D in N.NNN seconds.
          Set up ...E in N.NNN seconds.
          Set up ...F in N.NNN seconds.
          Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        Tearing down left over layers:
          Tear down ...F in N.NNN seconds.
          Tear down ...E in N.NNN seconds.
          Tear down ...D in N.NNN seconds.
          Tear down ...C in N.NNN seconds.
          Tear down ...B in N.NNN seconds.
          Tear down ...A in N.NNN seconds.
        
        
        >>> report() #doctest: +ELLIPSIS
        Report:
        ...A.setUp
        ...B.setUp
        ...C.setUp
        ...D.setUp
        ...E.setUp
        ...F.setUp
        ...A.testSetUp
        ...B.testSetUp
        ...C.testSetUp
        ...D.testSetUp
        ...E.testSetUp
        ...F.testSetUp
        ...F.testTearDown
        ...E.testTearDown
        ...D.testTearDown
        ...C.testTearDown
        ...B.testTearDown
        ...A.testTearDown
        ...F.tearDown
        ...E.tearDown
        ...D.tearDown
        ...C.tearDown
        ...B.tearDown
        ...A.tearDown
        
        
        Layer Selection
        ===============
        
        We can select which layers to run using the --layer option:
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test --layer 112 --layer Unit'.split()
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer112 tests:
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer112 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 182 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        
        We can also specify that we want to run only the unit tests:
        
            >>> sys.argv = 'test -u'.split()
            >>> testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Or that we want to run all of the tests except for the unit tests:
        
            >>> sys.argv = 'test -f'.split()
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer11 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer111 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer112 tests:
              Tear down samplelayers.Layer111 in N.NNN seconds.
              Set up samplelayers.Layer112 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer121 tests:
              Set up samplelayers.Layer121 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer122 tests:
              Tear down samplelayers.Layer121 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Total: 165 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        Or we can explicitly say that we want both unit and non-unit tests.
        
            >>> sys.argv = 'test -uf'.split()
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer11 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer111 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer112 tests:
              Tear down samplelayers.Layer111 in N.NNN seconds.
              Set up samplelayers.Layer112 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer121 tests:
              Set up samplelayers.Layer121 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer122 tests:
              Tear down samplelayers.Layer121 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 321 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        It is possible to force the layers to run in subprocesses and parallelize them.
        
            >>> sys.argv = [testrunner_script, '-j2']
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running samplelayers.Layer11 tests:
              Running in a subprocess.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer11 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running samplelayers.Layer111 tests:
              Running in a subprocess.
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer111 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer111 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running samplelayers.Layer112 tests:
              Running in a subprocess.
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer112 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running samplelayers.Layer12 tests:
              Running in a subprocess.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running samplelayers.Layer121 tests:
              Running in a subprocess.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Set up samplelayers.Layer121 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer121 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running samplelayers.Layer122 tests:
              Running in a subprocess.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Running in a subprocess.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer1 in N.NNN seconds.
            Total: 321 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        Passing arguments explicitly
        ============================
        
        In most of the examples here, we set up `sys.argv`.  In normal usage,
        the testrunner just uses `sys.argv`.  It is possible to pass arguments
        explicitly.
        
            >>> import os.path
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults, 'test --layer 111'.split())
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in N.NNN seconds.
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer11 in N.NNN seconds.
              Set up samplelayers.Layer111 in N.NNN seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer111 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            False
        
        If options already have default values, then passing a different default will
        override.
        
        For example, --list-tests defaults to being turned off, but if we pass in a
        different default, that one takes effect.
        
            >>> defaults = [
            ...     '--list-tests',
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults, 'test --layer 111'.split())
            Listing samplelayers.Layer111 tests:
              test_x1 (sample1.sampletests.test111.TestA)
              test_y0 (sample1.sampletests.test111.TestA)
              test_z0 (sample1.sampletests.test111.TestA)
              test_x0 (sample1.sampletests.test111.TestB)
              test_y1 (sample1.sampletests.test111.TestB)
              test_z0 (sample1.sampletests.test111.TestB)
              test_1 (sample1.sampletests.test111.TestNotMuch)
              test_2 (sample1.sampletests.test111.TestNotMuch)
              test_3 (sample1.sampletests.test111.TestNotMuch)
              test_x0 (sample1.sampletests.test111)
              test_y0 (sample1.sampletests.test111)
              test_z1 (sample1.sampletests.test111)
              /home/benji/workspace/zope.testrunner/1/src/zope/testing/testrunner/testrunner-ex/sample1/sampletests/../../sampletestsl.txt
              test_x1 (sampletests.test111.TestA)
              test_y0 (sampletests.test111.TestA)
              test_z0 (sampletests.test111.TestA)
              test_x0 (sampletests.test111.TestB)
              test_y1 (sampletests.test111.TestB)
              test_z0 (sampletests.test111.TestB)
              test_1 (sampletests.test111.TestNotMuch)
              test_2 (sampletests.test111.TestNotMuch)
              test_3 (sampletests.test111.TestNotMuch)
              test_x0 (sampletests.test111)
              test_y0 (sampletests.test111)
              test_z1 (sampletests.test111)
              /home/benji/workspace/zope.testrunner/1/src/zope/testing/testrunner/testrunner-ex/sampletests/../sampletestsl.txt
            False
        
        Verbose Output
        ==============
        
        Normally, we just get a summary.  We can use the -v option to get
        increasingly more information.
        
        If we use a single --verbose (-v) option, we get a dot printed for each
        test:
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
            >>> sys.argv = 'test --layer 122 -v'.split()
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                ..................................
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.007 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        If there are more than 50 tests, the dots are printed in groups of
        50:
        
            >>> sys.argv = 'test -uv'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
            ................................................................................................................................................................................................
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in 0.035 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        If the --verbose (-v) option is used twice, then the name and location of
        each test is printed as it is run:
        
            >>> sys.argv = 'test --layer 122 -vv'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                test_x1 (sample1.sampletests.test122.TestA)
                test_y0 (sample1.sampletests.test122.TestA)
                test_z0 (sample1.sampletests.test122.TestA)
                test_x0 (sample1.sampletests.test122.TestB)
                test_y1 (sample1.sampletests.test122.TestB)
                test_z0 (sample1.sampletests.test122.TestB)
                test_1 (sample1.sampletests.test122.TestNotMuch)
                test_2 (sample1.sampletests.test122.TestNotMuch)
                test_3 (sample1.sampletests.test122.TestNotMuch)
                test_x0 (sample1.sampletests.test122)
                test_y0 (sample1.sampletests.test122)
                test_z1 (sample1.sampletests.test122)
                testrunner-ex/sample1/sampletests/../../sampletestsl.txt
                test_x1 (sampletests.test122.TestA)
                test_y0 (sampletests.test122.TestA)
                test_z0 (sampletests.test122.TestA)
                test_x0 (sampletests.test122.TestB)
                test_y1 (sampletests.test122.TestB)
                test_z0 (sampletests.test122.TestB)
                test_1 (sampletests.test122.TestNotMuch)
                test_2 (sampletests.test122.TestNotMuch)
                test_3 (sampletests.test122.TestNotMuch)
                test_x0 (sampletests.test122)
                test_y0 (sampletests.test122)
                test_z1 (sampletests.test122)
                testrunner-ex/sampletests/../sampletestsl.txt
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.009 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        if the --verbose (-v) option is used three times, then individual
        test-execution times are printed:
        
            >>> sys.argv = 'test --layer 122 -vvv'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                test_x1 (sample1.sampletests.test122.TestA) (0.000 s)
                test_y0 (sample1.sampletests.test122.TestA) (0.000 s)
                test_z0 (sample1.sampletests.test122.TestA) (0.000 s)
                test_x0 (sample1.sampletests.test122.TestB) (0.000 s)
                test_y1 (sample1.sampletests.test122.TestB) (0.000 s)
                test_z0 (sample1.sampletests.test122.TestB) (0.000 s)
                test_1 (sample1.sampletests.test122.TestNotMuch) (0.000 s)
                test_2 (sample1.sampletests.test122.TestNotMuch) (0.000 s)
                test_3 (sample1.sampletests.test122.TestNotMuch) (0.000 s)
                test_x0 (sample1.sampletests.test122) (0.001 s)
                test_y0 (sample1.sampletests.test122) (0.001 s)
                test_z1 (sample1.sampletests.test122) (0.001 s)
                testrunner-ex/sample1/sampletests/../../sampletestsl.txt (0.001 s)
                test_x1 (sampletests.test122.TestA) (0.000 s)
                test_y0 (sampletests.test122.TestA) (0.000 s)
                test_z0 (sampletests.test122.TestA) (0.000 s)
                test_x0 (sampletests.test122.TestB) (0.000 s)
                test_y1 (sampletests.test122.TestB) (0.000 s)
                test_z0 (sampletests.test122.TestB) (0.000 s)
                test_1 (sampletests.test122.TestNotMuch) (0.000 s)
                test_2 (sampletests.test122.TestNotMuch) (0.000 s)
                test_3 (sampletests.test122.TestNotMuch) (0.000 s)
                test_x0 (sampletests.test122) (0.001 s)
                test_y0 (sampletests.test122) (0.001 s)
                test_z1 (sampletests.test122) (0.001 s)
                testrunner-ex/sampletests/../sampletestsl.txt (0.001 s)
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.009 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        Quiet output
        ------------
        
        The --quiet (-q) option cancels all verbose options.  It's useful when
        the default verbosity is non-zero:
        
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     '-v'
            ...     ]
            >>> sys.argv = 'test -q -u'.split()
            >>> testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in 0.034 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Test Selection
        ==============
        
        We've already seen that we can select tests by layer.  There are three
        other ways we can select tests.  We can select tests by package:
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test --layer 122 -ssample1 -vv'.split()
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                test_x1 (sample1.sampletests.test122.TestA)
                test_y0 (sample1.sampletests.test122.TestA)
                test_z0 (sample1.sampletests.test122.TestA)
                test_x0 (sample1.sampletests.test122.TestB)
                test_y1 (sample1.sampletests.test122.TestB)
                test_z0 (sample1.sampletests.test122.TestB)
                test_1 (sample1.sampletests.test122.TestNotMuch)
                test_2 (sample1.sampletests.test122.TestNotMuch)
                test_3 (sample1.sampletests.test122.TestNotMuch)
                test_x0 (sample1.sampletests.test122)
                test_y0 (sample1.sampletests.test122)
                test_z1 (sample1.sampletests.test122)
                testrunner-ex/sample1/sampletests/../../sampletestsl.txt
              Ran 13 tests with 0 failures, 0 errors and 0 skipped in 0.005 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        You can specify multiple packages:
        
            >>> sys.argv = 'test -u  -vv -ssample1 -ssample2'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_x1 (sample1.sampletestsf.TestA)
             test_y0 (sample1.sampletestsf.TestA)
             test_z0 (sample1.sampletestsf.TestA)
             test_x0 (sample1.sampletestsf.TestB)
             test_y1 (sample1.sampletestsf.TestB)
             test_z0 (sample1.sampletestsf.TestB)
             test_1 (sample1.sampletestsf.TestNotMuch)
             test_2 (sample1.sampletestsf.TestNotMuch)
             test_3 (sample1.sampletestsf.TestNotMuch)
             test_x0 (sample1.sampletestsf)
             test_y0 (sample1.sampletestsf)
             test_z1 (sample1.sampletestsf)
             testrunner-ex/sample1/../sampletests.txt
             test_x1 (sample1.sample11.sampletests.TestA)
             test_y0 (sample1.sample11.sampletests.TestA)
             test_z0 (sample1.sample11.sampletests.TestA)
             test_x0 (sample1.sample11.sampletests.TestB)
             test_y1 (sample1.sample11.sampletests.TestB)
             test_z0 (sample1.sample11.sampletests.TestB)
             test_1 (sample1.sample11.sampletests.TestNotMuch)
             test_2 (sample1.sample11.sampletests.TestNotMuch)
             test_3 (sample1.sample11.sampletests.TestNotMuch)
             test_x0 (sample1.sample11.sampletests)
             test_y0 (sample1.sample11.sampletests)
             test_z1 (sample1.sample11.sampletests)
             testrunner-ex/sample1/sample11/../../sampletests.txt
             test_x1 (sample1.sample13.sampletests.TestA)
             test_y0 (sample1.sample13.sampletests.TestA)
             test_z0 (sample1.sample13.sampletests.TestA)
             test_x0 (sample1.sample13.sampletests.TestB)
             test_y1 (sample1.sample13.sampletests.TestB)
             test_z0 (sample1.sample13.sampletests.TestB)
             test_1 (sample1.sample13.sampletests.TestNotMuch)
             test_2 (sample1.sample13.sampletests.TestNotMuch)
             test_3 (sample1.sample13.sampletests.TestNotMuch)
             test_x0 (sample1.sample13.sampletests)
             test_y0 (sample1.sample13.sampletests)
             test_z1 (sample1.sample13.sampletests)
             testrunner-ex/sample1/sample13/../../sampletests.txt
             test_x1 (sample1.sampletests.test1.TestA)
             test_y0 (sample1.sampletests.test1.TestA)
             test_z0 (sample1.sampletests.test1.TestA)
             test_x0 (sample1.sampletests.test1.TestB)
             test_y1 (sample1.sampletests.test1.TestB)
             test_z0 (sample1.sampletests.test1.TestB)
             test_1 (sample1.sampletests.test1.TestNotMuch)
             test_2 (sample1.sampletests.test1.TestNotMuch)
             test_3 (sample1.sampletests.test1.TestNotMuch)
             test_x0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test1)
             test_z1 (sample1.sampletests.test1)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             test_x1 (sample1.sampletests.test_one.TestA)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_z0 (sample1.sampletests.test_one.TestA)
             test_x0 (sample1.sampletests.test_one.TestB)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_z0 (sample1.sampletests.test_one.TestB)
             test_1 (sample1.sampletests.test_one.TestNotMuch)
             test_2 (sample1.sampletests.test_one.TestNotMuch)
             test_3 (sample1.sampletests.test_one.TestNotMuch)
             test_x0 (sample1.sampletests.test_one)
             test_y0 (sample1.sampletests.test_one)
             test_z1 (sample1.sampletests.test_one)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             test_x1 (sample2.sample21.sampletests.TestA)
             test_y0 (sample2.sample21.sampletests.TestA)
             test_z0 (sample2.sample21.sampletests.TestA)
             test_x0 (sample2.sample21.sampletests.TestB)
             test_y1 (sample2.sample21.sampletests.TestB)
             test_z0 (sample2.sample21.sampletests.TestB)
             test_1 (sample2.sample21.sampletests.TestNotMuch)
             test_2 (sample2.sample21.sampletests.TestNotMuch)
             test_3 (sample2.sample21.sampletests.TestNotMuch)
             test_x0 (sample2.sample21.sampletests)
             test_y0 (sample2.sample21.sampletests)
             test_z1 (sample2.sample21.sampletests)
             testrunner-ex/sample2/sample21/../../sampletests.txt
             test_x1 (sample2.sampletests.test_1.TestA)
             test_y0 (sample2.sampletests.test_1.TestA)
             test_z0 (sample2.sampletests.test_1.TestA)
             test_x0 (sample2.sampletests.test_1.TestB)
             test_y1 (sample2.sampletests.test_1.TestB)
             test_z0 (sample2.sampletests.test_1.TestB)
             test_1 (sample2.sampletests.test_1.TestNotMuch)
             test_2 (sample2.sampletests.test_1.TestNotMuch)
             test_3 (sample2.sampletests.test_1.TestNotMuch)
             test_x0 (sample2.sampletests.test_1)
             test_y0 (sample2.sampletests.test_1)
             test_z1 (sample2.sampletests.test_1)
             testrunner-ex/sample2/sampletests/../../sampletests.txt
             test_x1 (sample2.sampletests.testone.TestA)
             test_y0 (sample2.sampletests.testone.TestA)
             test_z0 (sample2.sampletests.testone.TestA)
             test_x0 (sample2.sampletests.testone.TestB)
             test_y1 (sample2.sampletests.testone.TestB)
             test_z0 (sample2.sampletests.testone.TestB)
             test_1 (sample2.sampletests.testone.TestNotMuch)
             test_2 (sample2.sampletests.testone.TestNotMuch)
             test_3 (sample2.sampletests.testone.TestNotMuch)
             test_x0 (sample2.sampletests.testone)
             test_y0 (sample2.sampletests.testone)
             test_z1 (sample2.sampletests.testone)
             testrunner-ex/sample2/sampletests/../../sampletests.txt
              Ran 104 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        You can specify directory names instead of packages (useful for
        tab-completion):
        
            >>> subdir = os.path.join(directory_with_tests, 'sample1')
            >>> sys.argv = ['test', '--layer', '122', '-s', subdir, '-vv']
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                test_x1 (sample1.sampletests.test122.TestA)
                test_y0 (sample1.sampletests.test122.TestA)
                test_z0 (sample1.sampletests.test122.TestA)
                test_x0 (sample1.sampletests.test122.TestB)
                test_y1 (sample1.sampletests.test122.TestB)
                test_z0 (sample1.sampletests.test122.TestB)
                test_1 (sample1.sampletests.test122.TestNotMuch)
                test_2 (sample1.sampletests.test122.TestNotMuch)
                test_3 (sample1.sampletests.test122.TestNotMuch)
                test_x0 (sample1.sampletests.test122)
                test_y0 (sample1.sampletests.test122)
                test_z1 (sample1.sampletests.test122)
                testrunner-ex/sample1/sampletests/../../sampletestsl.txt
              Ran 13 tests with 0 failures, 0 errors and 0 skipped in 0.005 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        We can select by test module name using the --module (-m) option:
        
            >>> sys.argv = 'test -u  -vv -ssample1 -m_one -mtest1'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_x1 (sample1.sampletests.test1.TestA)
             test_y0 (sample1.sampletests.test1.TestA)
             test_z0 (sample1.sampletests.test1.TestA)
             test_x0 (sample1.sampletests.test1.TestB)
             test_y1 (sample1.sampletests.test1.TestB)
             test_z0 (sample1.sampletests.test1.TestB)
             test_1 (sample1.sampletests.test1.TestNotMuch)
             test_2 (sample1.sampletests.test1.TestNotMuch)
             test_3 (sample1.sampletests.test1.TestNotMuch)
             test_x0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test1)
             test_z1 (sample1.sampletests.test1)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             test_x1 (sample1.sampletests.test_one.TestA)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_z0 (sample1.sampletests.test_one.TestA)
             test_x0 (sample1.sampletests.test_one.TestB)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_z0 (sample1.sampletests.test_one.TestB)
             test_1 (sample1.sampletests.test_one.TestNotMuch)
             test_2 (sample1.sampletests.test_one.TestNotMuch)
             test_3 (sample1.sampletests.test_one.TestNotMuch)
             test_x0 (sample1.sampletests.test_one)
             test_y0 (sample1.sampletests.test_one)
             test_z1 (sample1.sampletests.test_one)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        and by test within the module using the --test (-t) option:
        
            >>> sys.argv = 'test -u  -vv -ssample1 -m_one -mtest1 -tx0 -ty0'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_y0 (sample1.sampletests.test1.TestA)
             test_x0 (sample1.sampletests.test1.TestB)
             test_x0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_x0 (sample1.sampletests.test_one.TestB)
             test_x0 (sample1.sampletests.test_one)
             test_y0 (sample1.sampletests.test_one)
              Ran 8 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
            >>> sys.argv = 'test -u  -vv -ssample1 -ttxt'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             testrunner-ex/sample1/../sampletests.txt
             testrunner-ex/sample1/sample11/../../sampletests.txt
             testrunner-ex/sample1/sample13/../../sampletests.txt
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             testrunner-ex/sample1/sampletests/../../sampletests.txt
              Ran 5 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        The --module and --test options take regular expressions.  If the
        regular expressions specified begin with '!', then tests that don't
        match the regular expression are selected:
        
            >>> sys.argv = 'test -u  -vv -ssample1 -m!sample1[.]sample1'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_x1 (sample1.sampletestsf.TestA)
             test_y0 (sample1.sampletestsf.TestA)
             test_z0 (sample1.sampletestsf.TestA)
             test_x0 (sample1.sampletestsf.TestB)
             test_y1 (sample1.sampletestsf.TestB)
             test_z0 (sample1.sampletestsf.TestB)
             test_1 (sample1.sampletestsf.TestNotMuch)
             test_2 (sample1.sampletestsf.TestNotMuch)
             test_3 (sample1.sampletestsf.TestNotMuch)
             test_x0 (sample1.sampletestsf)
             test_y0 (sample1.sampletestsf)
             test_z1 (sample1.sampletestsf)
             testrunner-ex/sample1/../sampletests.txt
             test_x1 (sample1.sampletests.test1.TestA)
             test_y0 (sample1.sampletests.test1.TestA)
             test_z0 (sample1.sampletests.test1.TestA)
             test_x0 (sample1.sampletests.test1.TestB)
             test_y1 (sample1.sampletests.test1.TestB)
             test_z0 (sample1.sampletests.test1.TestB)
             test_1 (sample1.sampletests.test1.TestNotMuch)
             test_2 (sample1.sampletests.test1.TestNotMuch)
             test_3 (sample1.sampletests.test1.TestNotMuch)
             test_x0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test1)
             test_z1 (sample1.sampletests.test1)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             test_x1 (sample1.sampletests.test_one.TestA)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_z0 (sample1.sampletests.test_one.TestA)
             test_x0 (sample1.sampletests.test_one.TestB)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_z0 (sample1.sampletests.test_one.TestB)
             test_1 (sample1.sampletests.test_one.TestNotMuch)
             test_2 (sample1.sampletests.test_one.TestNotMuch)
             test_3 (sample1.sampletests.test_one.TestNotMuch)
             test_x0 (sample1.sampletests.test_one)
             test_y0 (sample1.sampletests.test_one)
             test_z1 (sample1.sampletests.test_one)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
              Ran 39 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Module and test filters can also be given as positional arguments:
        
        
            >>> sys.argv = 'test -u  -vv -ssample1 !sample1[.]sample1'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_x1 (sample1.sampletestsf.TestA)
             test_y0 (sample1.sampletestsf.TestA)
             test_z0 (sample1.sampletestsf.TestA)
             test_x0 (sample1.sampletestsf.TestB)
             test_y1 (sample1.sampletestsf.TestB)
             test_z0 (sample1.sampletestsf.TestB)
             test_1 (sample1.sampletestsf.TestNotMuch)
             test_2 (sample1.sampletestsf.TestNotMuch)
             test_3 (sample1.sampletestsf.TestNotMuch)
             test_x0 (sample1.sampletestsf)
             test_y0 (sample1.sampletestsf)
             test_z1 (sample1.sampletestsf)
             testrunner-ex/sample1/../sampletests.txt
             test_x1 (sample1.sampletests.test1.TestA)
             test_y0 (sample1.sampletests.test1.TestA)
             test_z0 (sample1.sampletests.test1.TestA)
             test_x0 (sample1.sampletests.test1.TestB)
             test_y1 (sample1.sampletests.test1.TestB)
             test_z0 (sample1.sampletests.test1.TestB)
             test_1 (sample1.sampletests.test1.TestNotMuch)
             test_2 (sample1.sampletests.test1.TestNotMuch)
             test_3 (sample1.sampletests.test1.TestNotMuch)
             test_x0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test1)
             test_z1 (sample1.sampletests.test1)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             test_x1 (sample1.sampletests.test_one.TestA)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_z0 (sample1.sampletests.test_one.TestA)
             test_x0 (sample1.sampletests.test_one.TestB)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_z0 (sample1.sampletests.test_one.TestB)
             test_1 (sample1.sampletests.test_one.TestNotMuch)
             test_2 (sample1.sampletests.test_one.TestNotMuch)
             test_3 (sample1.sampletests.test_one.TestNotMuch)
             test_x0 (sample1.sampletests.test_one)
             test_y0 (sample1.sampletests.test_one)
             test_z1 (sample1.sampletests.test_one)
             testrunner-ex/sample1/sampletests/../../sampletests.txt
              Ran 39 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
            >>> sys.argv = 'test -u  -vv -ssample1 . txt'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             testrunner-ex/sample1/../sampletests.txt
             testrunner-ex/sample1/sample11/../../sampletests.txt
             testrunner-ex/sample1/sample13/../../sampletests.txt
             testrunner-ex/sample1/sampletests/../../sampletests.txt
             testrunner-ex/sample1/sampletests/../../sampletests.txt
              Ran 5 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Sometimes, There are tests that you don't want to run by default.
        For example, you might have tests that take a long time.  Tests can
        have a level attribute.  If no level is specified, a level of 1 is
        assumed and, by default, only tests at level one are run.  to run
        tests at a higher level, use the --at-level (-a) option to specify a higher
        level.  For example, with the following options:
        
        
            >>> sys.argv = 'test -u  -vv -t test_y1 -t test_y0'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_y0 (sampletestsf.TestA)
             test_y1 (sampletestsf.TestB)
             test_y0 (sampletestsf)
             test_y0 (sample1.sampletestsf.TestA)
             test_y1 (sample1.sampletestsf.TestB)
             test_y0 (sample1.sampletestsf)
             test_y0 (sample1.sample11.sampletests.TestA)
             test_y1 (sample1.sample11.sampletests.TestB)
             test_y0 (sample1.sample11.sampletests)
             test_y0 (sample1.sample13.sampletests.TestA)
             test_y1 (sample1.sample13.sampletests.TestB)
             test_y0 (sample1.sample13.sampletests)
             test_y0 (sample1.sampletests.test1.TestA)
             test_y1 (sample1.sampletests.test1.TestB)
             test_y0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_y0 (sample1.sampletests.test_one)
             test_y0 (sample2.sample21.sampletests.TestA)
             test_y1 (sample2.sample21.sampletests.TestB)
             test_y0 (sample2.sample21.sampletests)
             test_y0 (sample2.sampletests.test_1.TestA)
             test_y1 (sample2.sampletests.test_1.TestB)
             test_y0 (sample2.sampletests.test_1)
             test_y0 (sample2.sampletests.testone.TestA)
             test_y1 (sample2.sampletests.testone.TestB)
             test_y0 (sample2.sampletests.testone)
             test_y0 (sample3.sampletests.TestA)
             test_y1 (sample3.sampletests.TestB)
             test_y0 (sample3.sampletests)
             test_y0 (sampletests.test1.TestA)
             test_y1 (sampletests.test1.TestB)
             test_y0 (sampletests.test1)
             test_y0 (sampletests.test_one.TestA)
             test_y1 (sampletests.test_one.TestB)
             test_y0 (sampletests.test_one)
              Ran 36 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        We get run 36 tests.  If we specify a level of 2, we get some
        additional tests:
        
            >>> sys.argv = 'test -u  -vv -a 2 -t test_y1 -t test_y0'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 2
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_y0 (sampletestsf.TestA)
             test_y0 (sampletestsf.TestA2)
             test_y1 (sampletestsf.TestB)
             test_y0 (sampletestsf)
             test_y0 (sample1.sampletestsf.TestA)
             test_y1 (sample1.sampletestsf.TestB)
             test_y0 (sample1.sampletestsf)
             test_y0 (sample1.sample11.sampletests.TestA)
             test_y1 (sample1.sample11.sampletests.TestB)
             test_y1 (sample1.sample11.sampletests.TestB2)
             test_y0 (sample1.sample11.sampletests)
             test_y0 (sample1.sample13.sampletests.TestA)
             test_y1 (sample1.sample13.sampletests.TestB)
             test_y0 (sample1.sample13.sampletests)
             test_y0 (sample1.sampletests.test1.TestA)
             test_y1 (sample1.sampletests.test1.TestB)
             test_y0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_y0 (sample1.sampletests.test_one)
             test_y0 (sample2.sample21.sampletests.TestA)
             test_y1 (sample2.sample21.sampletests.TestB)
             test_y0 (sample2.sample21.sampletests)
             test_y0 (sample2.sampletests.test_1.TestA)
             test_y1 (sample2.sampletests.test_1.TestB)
             test_y0 (sample2.sampletests.test_1)
             test_y0 (sample2.sampletests.testone.TestA)
             test_y1 (sample2.sampletests.testone.TestB)
             test_y0 (sample2.sampletests.testone)
             test_y0 (sample3.sampletests.TestA)
             test_y1 (sample3.sampletests.TestB)
             test_y0 (sample3.sampletests)
             test_y0 (sampletests.test1.TestA)
             test_y1 (sampletests.test1.TestB)
             test_y0 (sampletests.test1)
             test_y0 (sampletests.test_one.TestA)
             test_y1 (sampletests.test_one.TestB)
             test_y0 (sampletests.test_one)
              Ran 38 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        We can use the --all option to run tests at all levels:
        
            >>> sys.argv = 'test -u  -vv --all -t test_y1 -t test_y0'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at all levels
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_y0 (sampletestsf.TestA)
             test_y0 (sampletestsf.TestA2)
             test_y1 (sampletestsf.TestB)
             test_y0 (sampletestsf)
             test_y0 (sample1.sampletestsf.TestA)
             test_y1 (sample1.sampletestsf.TestB)
             test_y0 (sample1.sampletestsf)
             test_y0 (sample1.sample11.sampletests.TestA)
             test_y0 (sample1.sample11.sampletests.TestA3)
             test_y1 (sample1.sample11.sampletests.TestB)
             test_y1 (sample1.sample11.sampletests.TestB2)
             test_y0 (sample1.sample11.sampletests)
             test_y0 (sample1.sample13.sampletests.TestA)
             test_y1 (sample1.sample13.sampletests.TestB)
             test_y0 (sample1.sample13.sampletests)
             test_y0 (sample1.sampletests.test1.TestA)
             test_y1 (sample1.sampletests.test1.TestB)
             test_y0 (sample1.sampletests.test1)
             test_y0 (sample1.sampletests.test_one.TestA)
             test_y1 (sample1.sampletests.test_one.TestB)
             test_y0 (sample1.sampletests.test_one)
             test_y0 (sample2.sample21.sampletests.TestA)
             test_y1 (sample2.sample21.sampletests.TestB)
             test_y0 (sample2.sample21.sampletests)
             test_y0 (sample2.sampletests.test_1.TestA)
             test_y1 (sample2.sampletests.test_1.TestB)
             test_y0 (sample2.sampletests.test_1)
             test_y0 (sample2.sampletests.testone.TestA)
             test_y1 (sample2.sampletests.testone.TestB)
             test_y0 (sample2.sampletests.testone)
             test_y0 (sample3.sampletests.TestA)
             test_y1 (sample3.sampletests.TestB)
             test_y0 (sample3.sampletests)
             test_y0 (sampletests.test1.TestA)
             test_y1 (sampletests.test1.TestB)
             test_y0 (sampletests.test1)
             test_y0 (sampletests.test_one.TestA)
             test_y1 (sampletests.test_one.TestB)
             test_y0 (sampletests.test_one)
              Ran 39 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Listing Selected Tests
        ----------------------
        
        When you're trying to figure out why the test you want is not matched by the
        pattern you specified, it is convenient to see which tests match your
        specifications.
        
            >>> sys.argv = 'test --all -m sample1 -t test_y0 --list-tests'.split()
            >>> testrunner.run_internal(defaults)
            Listing samplelayers.Layer11 tests:
              test_y0 (sample1.sampletests.test11.TestA)
              test_y0 (sample1.sampletests.test11)
            Listing samplelayers.Layer111 tests:
              test_y0 (sample1.sampletests.test111.TestA)
              test_y0 (sample1.sampletests.test111)
            Listing samplelayers.Layer112 tests:
              test_y0 (sample1.sampletests.test112.TestA)
              test_y0 (sample1.sampletests.test112)
            Listing samplelayers.Layer12 tests:
              test_y0 (sample1.sampletests.test12.TestA)
              test_y0 (sample1.sampletests.test12)
            Listing samplelayers.Layer121 tests:
              test_y0 (sample1.sampletests.test121.TestA)
              test_y0 (sample1.sampletests.test121)
            Listing samplelayers.Layer122 tests:
              test_y0 (sample1.sampletests.test122.TestA)
              test_y0 (sample1.sampletests.test122)
            Listing zope.testrunner.layer.UnitTests tests:
              test_y0 (sample1.sampletestsf.TestA)
              test_y0 (sample1.sampletestsf)
              test_y0 (sample1.sample11.sampletests.TestA)
              test_y0 (sample1.sample11.sampletests.TestA3)
              test_y0 (sample1.sample11.sampletests)
              test_y0 (sample1.sample13.sampletests.TestA)
              test_y0 (sample1.sample13.sampletests)
              test_y0 (sample1.sampletests.test1.TestA)
              test_y0 (sample1.sampletests.test1)
              test_y0 (sample1.sampletests.test_one.TestA)
              test_y0 (sample1.sampletests.test_one)
            False
        
        Test Progress
        =============
        
        If the --progress (-p) option is used, progress information is printed and
        a carriage return (rather than a new-line) is printed between
        detail lines.  Let's look at the effect of --progress (-p) at different
        levels of verbosity.
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test --layer 122 -p'.split()
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Running:
                1/26 (3.8%)##r##
                           ##r##
                2/26 (7.7%)##r##
                           ##r##
                3/26 (11.5%)##r##
                            ##r##
                4/26 (15.4%)##r##
                            ##r##
                5/26 (19.2%)##r##
                            ##r##
                6/26 (23.1%)##r##
                            ##r##
                7/26 (26.9%)##r##
                            ##r##
                8/26 (30.8%)##r##
                            ##r##
                9/26 (34.6%)##r##
                            ##r##
                10/26 (38.5%)##r##
                             ##r##
                11/26 (42.3%)##r##
                             ##r##
                12/26 (46.2%)##r##
                             ##r##
                13/26 (50.0%)##r##
                             ##r##
                14/26 (53.8%)##r##
                             ##r##
                15/26 (57.7%)##r##
                             ##r##
                16/26 (61.5%)##r##
                             ##r##
                17/26 (65.4%)##r##
                             ##r##
                18/26 (69.2%)##r##
                             ##r##
                19/26 (73.1%)##r##
                             ##r##
                20/26 (76.9%)##r##
                             ##r##
                21/26 (80.8%)##r##
                             ##r##
                22/26 (84.6%)##r##
                             ##r##
                23/26 (88.5%)##r##
                             ##r##
                24/26 (92.3%)##r##
                             ##r##
                25/26 (96.2%)##r##
                             ##r##
                26/26 (100.0%)##r##
                              ##r##
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            False
        
        
        (Note that, in the examples above and below, we show "##r##" followed by
        new lines where carriage returns would appear in actual output.)
        
        Using a single level of verbosity causes test descriptions to be
        output, but only if they fit in the terminal width.  The default
        width, when the terminal width can't be determined, is 80:
        
            >>> sys.argv = 'test --layer 122 -pv'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Running:
                1/26 (3.8%) test_x1 (sample1.sampletests.test122.TestA)##r##
                                                                       ##r##
                2/26 (7.7%) test_y0 (sample1.sampletests.test122.TestA)##r##
                                                                       ##r##
                3/26 (11.5%) test_z0 (sample1.sampletests.test122.TestA)##r##
                                                                        ##r##
                4/26 (15.4%) test_x0 (sample1.sampletests.test122.TestB)##r##
                                                                        ##r##
                5/26 (19.2%) test_y1 (sample1.sampletests.test122.TestB)##r##
                                                                        ##r##
                6/26 (23.1%) test_z0 (sample1.sampletests.test122.TestB)##r##
                                                                        ##r##
                7/26 (26.9%) test_1 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                             ##r##
                8/26 (30.8%) test_2 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                             ##r##
                9/26 (34.6%) test_3 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                             ##r##
                10/26 (38.5%) test_x0 (sample1.sampletests.test122)##r##
                                                                   ##r##
                11/26 (42.3%) test_y0 (sample1.sampletests.test122)##r##
                                                                   ##r##
                12/26 (46.2%) test_z1 (sample1.sampletests.test122)##r##
                                                                   ##r##
             testrunner-ex/sample1/sampletests/../../sampletestsl.txt##r##
                                                                                           ##r##
                14/26 (53.8%) test_x1 (sampletests.test122.TestA)##r##
                                                                 ##r##
                15/26 (57.7%) test_y0 (sampletests.test122.TestA)##r##
                                                                 ##r##
                16/26 (61.5%) test_z0 (sampletests.test122.TestA)##r##
                                                                 ##r##
                17/26 (65.4%) test_x0 (sampletests.test122.TestB)##r##
                                                                 ##r##
                18/26 (69.2%) test_y1 (sampletests.test122.TestB)##r##
                                                                 ##r##
                19/26 (73.1%) test_z0 (sampletests.test122.TestB)##r##
                                                                 ##r##
                20/26 (76.9%) test_1 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                21/26 (80.8%) test_2 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                22/26 (84.6%) test_3 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                23/26 (88.5%) test_x0 (sampletests.test122)##r##
                                                           ##r##
                24/26 (92.3%) test_y0 (sampletests.test122)##r##
                                                           ##r##
                25/26 (96.2%) test_z1 (sampletests.test122)##r##
                                                           ##r##
             testrunner-ex/sampletests/../sampletestsl.txt##r##
                                                                                           ##r##
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            False
        
        
        The terminal width is determined using the curses module.  To see
        that, we'll provide a fake curses module:
        
            >>> class FakeCurses:
            ...     class error(Exception):
            ...         pass
            ...     def setupterm(self):
            ...         pass
            ...     def tigetnum(self, ignored):
            ...         return 60
            >>> old_curses = sys.modules.get('curses')
            >>> sys.modules['curses'] = FakeCurses()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in N.NNN seconds.
              Set up samplelayers.Layer12 in N.NNN seconds.
              Set up samplelayers.Layer122 in N.NNN seconds.
              Running:
                1/26 (3.8%) test_x1 (sample1.sampletests.test122.TestA)##r##
                                                                       ##r##
                2/26 (7.7%) test_y0 (sample1.sampletests.test122.TestA)##r##
                                                                       ##r##
                3/26 (11.5%) test_z0 (...le1.sampletests.test122.TestA)##r##
                                                                       ##r##
                4/26 (15.4%) test_x0 (...le1.sampletests.test122.TestB)##r##
                                                                       ##r##
                5/26 (19.2%) test_y1 (...le1.sampletests.test122.TestB)##r##
                                                                       ##r##
                6/26 (23.1%) test_z0 (...le1.sampletests.test122.TestB)##r##
                                                                       ##r##
                7/26 (26.9%) test_1 (...ampletests.test122.TestNotMuch)##r##
                                                                       ##r##
                8/26 (30.8%) test_2 (...ampletests.test122.TestNotMuch)##r##
                                                                       ##r##
                9/26 (34.6%) test_3 (...ampletests.test122.TestNotMuch)##r##
                                                                       ##r##
                10/26 (38.5%) test_x0 (sample1.sampletests.test122)##r##
                                                                   ##r##
                11/26 (42.3%) test_y0 (sample1.sampletests.test122)##r##
                                                                   ##r##
                12/26 (46.2%) test_z1 (sample1.sampletests.test122)##r##
                                                                   ##r##
                13/26 (50.0%) ... e1/sampletests/../../sampletestsl.txt##r##
                                                                       ##r##
                14/26 (53.8%) test_x1 (sampletests.test122.TestA)##r##
                                                                 ##r##
                15/26 (57.7%) test_y0 (sampletests.test122.TestA)##r##
                                                                 ##r##
                16/26 (61.5%) test_z0 (sampletests.test122.TestA)##r##
                                                                 ##r##
                17/26 (65.4%) test_x0 (sampletests.test122.TestB)##r##
                                                                 ##r##
                18/26 (69.2%) test_y1 (sampletests.test122.TestB)##r##
                                                                 ##r##
                19/26 (73.1%) test_z0 (sampletests.test122.TestB)##r##
                                                                 ##r##
                20/26 (76.9%) test_1 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                21/26 (80.8%) test_2 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                22/26 (84.6%) test_3 (sampletests.test122.TestNotMuch)##r##
                                                                      ##r##
                23/26 (88.5%) test_x0 (sampletests.test122)##r##
                                                           ##r##
                24/26 (92.3%) test_y0 (sampletests.test122)##r##
                                                           ##r##
                25/26 (96.2%) test_z1 (sampletests.test122)##r##
                                                           ##r##
                26/26 (100.0%) ... r-ex/sampletests/../sampletestsl.txt##r##
                                                                       ##r##
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
            False
        
            >>> sys.modules['curses'] = old_curses
        
        If a second or third level of verbosity are added, we get additional
        information.
        
            >>> sys.argv = 'test --layer 122 -pvv -t !txt'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                1/24 (4.2%) test_x1 (sample1.sampletests.test122.TestA)##r##
                                                                      ##r##
                2/24 (8.3%) test_y0 (sample1.sampletests.test122.TestA)##r##
                                                                      ##r##
                3/24 (12.5%) test_z0 (sample1.sampletests.test122.TestA)##r##
                                                                       ##r##
                4/24 (16.7%) test_x0 (sample1.sampletests.test122.TestB)##r##
                                                                       ##r##
                5/24 (20.8%) test_y1 (sample1.sampletests.test122.TestB)##r##
                                                                       ##r##
                6/24 (25.0%) test_z0 (sample1.sampletests.test122.TestB)##r##
                                                                       ##r##
                7/24 (29.2%) test_1 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                            ##r##
                8/24 (33.3%) test_2 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                            ##r##
                9/24 (37.5%) test_3 (sample1.sampletests.test122.TestNotMuch)##r##
                                                                            ##r##
                10/24 (41.7%) test_x0 (sample1.sampletests.test122)##r##
                                                                  ##r##
                11/24 (45.8%) test_y0 (sample1.sampletests.test122)##r##
                                                                  ##r##
                12/24 (50.0%) test_z1 (sample1.sampletests.test122)##r##
                                                                  ##r##
                13/24 (54.2%) test_x1 (sampletests.test122.TestA)##r##
                                                                ##r##
                14/24 (58.3%) test_y0 (sampletests.test122.TestA)##r##
                                                                ##r##
                15/24 (62.5%) test_z0 (sampletests.test122.TestA)##r##
                                                                ##r##
                16/24 (66.7%) test_x0 (sampletests.test122.TestB)##r##
                                                                ##r##
                17/24 (70.8%) test_y1 (sampletests.test122.TestB)##r##
                                                                ##r##
                18/24 (75.0%) test_z0 (sampletests.test122.TestB)##r##
                                                                ##r##
                19/24 (79.2%) test_1 (sampletests.test122.TestNotMuch)##r##
                                                                     ##r##
                20/24 (83.3%) test_2 (sampletests.test122.TestNotMuch)##r##
                                                                     ##r##
                21/24 (87.5%) test_3 (sampletests.test122.TestNotMuch)##r##
                                                                     ##r##
                22/24 (91.7%) test_x0 (sampletests.test122)##r##
                                                          ##r##
                23/24 (95.8%) test_y0 (sampletests.test122)##r##
                                                          ##r##
                24/24 (100.0%) test_z1 (sampletests.test122)##r##
                                                           ##r##
              Ran 24 tests with 0 failures, 0 errors and 0 skipped in 0.006 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        Note that, in this example, we used a test-selection pattern starting
        with '!' to exclude tests containing the string "txt".
        
            >>> sys.argv = 'test --layer 122 -pvvv -t!(txt|NotMuch)'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer122 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Running:
                1/18 (5.6%) test_x1 (sample1.sampletests.test122.TestA) (0.000 s)##r##
                                                                                  ##r##
                2/18 (11.1%) test_y0 (sample1.sampletests.test122.TestA) (0.000 s)##r##
                                                                                   ##r##
                3/18 (16.7%) test_z0 (sample1.sampletests.test122.TestA) (0.000 s)##r##
                                                                                   ##r##
                4/18 (22.2%) test_x0 (sample1.sampletests.test122.TestB) (0.000 s)##r##
                                                                                   ##r##
                5/18 (27.8%) test_y1 (sample1.sampletests.test122.TestB) (0.000 s)##r##
                                                                                   ##r##
                6/18 (33.3%) test_z0 (sample1.sampletests.test122.TestB) (0.000 s)##r##
                                                                                   ##r##
                7/18 (38.9%) test_x0 (sample1.sampletests.test122) (0.001 s)##r##
                                                                             ##r##
                8/18 (44.4%) test_y0 (sample1.sampletests.test122) (0.001 s)##r##
                                                                             ##r##
                9/18 (50.0%) test_z1 (sample1.sampletests.test122) (0.001 s)##r##
                                                                             ##r##
                10/18 (55.6%) test_x1 (sampletests.test122.TestA) (0.000 s)##r##
                                                                            ##r##
                11/18 (61.1%) test_y0 (sampletests.test122.TestA) (0.000 s)##r##
                                                                            ##r##
                12/18 (66.7%) test_z0 (sampletests.test122.TestA) (0.000 s)##r##
                                                                            ##r##
                13/18 (72.2%) test_x0 (sampletests.test122.TestB) (0.000 s)##r##
                                                                            ##r##
                14/18 (77.8%) test_y1 (sampletests.test122.TestB) (0.000 s)##r##
                                                                            ##r##
                15/18 (83.3%) test_z0 (sampletests.test122.TestB) (0.000 s)##r##
                                                                            ##r##
                16/18 (88.9%) test_x0 (sampletests.test122) (0.001 s)##r##
                                                                      ##r##
                17/18 (94.4%) test_y0 (sampletests.test122) (0.001 s)##r##
                                                                      ##r##
                18/18 (100.0%) test_z1 (sampletests.test122) (0.001 s)##r##
                                                                       ##r##
              Ran 18 tests with 0 failures, 0 errors and 0 skipped in 0.006 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        In this example, we also excluded tests with "NotMuch" in their names.
        
        Unfortunately, the time data above doesn't buy us much because, in
        practice, the line is cleared before there is time to see the
        times. :/
        
        
        Autodetecting progress
        ----------------------
        
        The --auto-progress option will determine if stdout is a terminal, and only enable
        progress output if so.
        
        Let's pretend we have a terminal
        
            >>> class Terminal(object):
            ...     def __init__(self, stream):
            ...         self._stream = stream
            ...     def __getattr__(self, attr):
            ...         return getattr(self._stream, attr)
            ...     def isatty(self):
            ...         return True
            >>> real_stdout = sys.stdout
            >>> sys.stdout = Terminal(sys.stdout)
        
            >>> sys.argv = 'test -u -t test_one.TestNotMuch --auto-progress'.split()
            >>> testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
                1/6 (16.7%)##r##
                           ##r##
                2/6 (33.3%)##r##
                           ##r##
                3/6 (50.0%)##r##
                           ##r##
                4/6 (66.7%)##r##
                           ##r##
                5/6 (83.3%)##r##
                           ##r##
                6/6 (100.0%)##r##
                            ##r##
              Ran 6 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Let's stop pretending
        
            >>> sys.stdout = real_stdout
        
            >>> sys.argv = 'test -u -t test_one.TestNotMuch --auto-progress'.split()
            >>> testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 6 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Disabling progress indication
        -----------------------------
        
        If -p or --progress have been previously provided on the command line (perhaps by a
        wrapper script) but you do not desire progress indication, you can switch it off with
        --no-progress:
        
            >>> sys.argv = 'test -u -t test_one.TestNotMuch -p --no-progress'.split()
            >>> testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 6 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Debugging
        =========
        
        The testrunner module supports post-mortem debugging and debugging
        using `pdb.set_trace`.  Let's look first at using `pdb.set_trace`.
        To demonstrate this, we'll provide input via helper Input objects:
        
            >>> class Input:
            ...     def __init__(self, src):
            ...         self.lines = src.split('\n')
            ...     def readline(self):
            ...         line = self.lines.pop(0)
            ...         print(line)
            ...         return line+'\n'
        
        If a test or code called by a test calls pdb.set_trace, then the
        runner will enter pdb at that point:
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> from zope import testrunner
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> real_stdin = sys.stdin
            >>> sys.stdin = Input('p x\nc')
        
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace1').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +ELLIPSIS
            Running zope.testrunner.layer.UnitTests tests:
            ...
            > testrunner-ex/sample3/sampletests_d.py(27)test_set_trace1()
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
            ...
            False
        
        Note that, prior to Python 2.4, calling pdb.set_trace caused pdb to
        break in the pdb.set_trace function.  It was necessary to use 'next'
        or 'up' to get to the application code that called pdb.set_trace.  In
        Python 2.4, pdb.set_trace causes pdb to stop right after the call to
        pdb.set_trace.
        
        You can also do post-mortem debugging, using the --post-mortem (-D)
        option:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem1 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF +ELLIPSIS
            Running zope.testrunner.layer.UnitTests tests:
            ...
            Error in test test_post_mortem1 (sample3.sampletests_d.TestSomething)
            Traceback (most recent call last):
              File "testrunner-ex/sample3/sampletests_d.py",
                      line 34, in test_post_mortem1
                raise ValueError
            ValueError
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(34)test_post_mortem1()
            -> raise ValueError
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Note that the test runner exits after post-mortem debugging.
        
        In the example above, we debugged an error.  Failures are actually
        converted to errors and can be debugged the same way:
        
            >>> sys.stdin = Input('p x\np y\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem_failure1 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF +ELLIPSIS
            Running zope.testrunner.layer.UnitTests tests:
            ...
            Error in test test_post_mortem_failure1 (sample3.sampletests_d.TestSomething)
            Traceback (most recent call last):
              File ".../unittest.py",  line 252, in debug
                getattr(self, self.__testMethodName)()
              File "testrunner-ex/sample3/sampletests_d.py",
                line 42, in test_post_mortem_failure1
                assert x == y
            AssertionError
            <BLANKLINE>
            ...AssertionError
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(42)test_post_mortem_failure1()
            -> assert x == y
            (Pdb) p x
            1
            (Pdb) p y
            2
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Layers that can't be torn down
        ==============================
        
        A layer can have a tearDown method that raises NotImplementedError.
        If this is the case and there are no remaining tests to run, the test
        runner will just note that the tear down couldn't be done:
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> from zope import testrunner
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test -ssample2 --tests-pattern sampletests_ntd$'.split()
            >>> testrunner.run_internal(defaults)
            Running sample2.sampletests_ntd.Layer tests:
              Set up sample2.sampletests_ntd.Layer in 0.000 seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Tearing down left over layers:
              Tear down sample2.sampletests_ntd.Layer ... not supported
            False
        
        If the tearDown method raises NotImplementedError and there are remaining
        layers to run, the test runner will restart itself as a new process,
        resuming tests where it left off:
        
            >>> sys.argv = [testrunner_script, '--tests-pattern', 'sampletests_ntd$']
            >>> testrunner.run_internal(defaults)
            Running sample1.sampletests_ntd.Layer tests:
              Set up sample1.sampletests_ntd.Layer in N.NNN seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running sample2.sampletests_ntd.Layer tests:
              Tear down sample1.sampletests_ntd.Layer ... not supported
              Running in a subprocess.
              Set up sample2.sampletests_ntd.Layer in N.NNN seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down sample2.sampletests_ntd.Layer ... not supported
            Running sample3.sampletests_ntd.Layer tests:
              Running in a subprocess.
              Set up sample3.sampletests_ntd.Layer in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_error1 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_error1
                raise TypeError("Can we see errors")
            TypeError: Can we see errors
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_error2 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_error2
                raise TypeError("I hope so")
            TypeError: I hope so
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Failure in test test_fail1 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_fail1
                self.assertEqual(1, 2)
            AssertionError: 1 != 2
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Failure in test test_fail2 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_fail2
                self.assertEqual(1, 3)
            AssertionError: 1 != 3
            <BLANKLINE>
              Ran 6 tests with 2 failures, 2 errors and 0 skipped in N.NNN seconds.
              Tear down sample3.sampletests_ntd.Layer ... not supported
            Total: 8 tests, 2 failures, 2 errors and 0 skipped in N.NNN seconds.
            True
        
        in the example above, some of the tests run as a subprocess had errors
        and failures. They were displayed as usual and the failure and error
        statistice were updated as usual.
        
        Note that debugging doesn't work when running tests in a subprocess:
        
            >>> sys.argv = [testrunner_script, '--tests-pattern', 'sampletests_ntd$',
            ...             '-D', ]
            >>> testrunner.run_internal(defaults)
            Running sample1.sampletests_ntd.Layer tests:
              Set up sample1.sampletests_ntd.Layer in N.NNN seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Running sample2.sampletests_ntd.Layer tests:
              Tear down sample1.sampletests_ntd.Layer ... not supported
              Running in a subprocess.
              Set up sample2.sampletests_ntd.Layer in N.NNN seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
              Tear down sample2.sampletests_ntd.Layer ... not supported
            Running sample3.sampletests_ntd.Layer tests:
              Running in a subprocess.
              Set up sample3.sampletests_ntd.Layer in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_error1 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_error1
                raise TypeError("Can we see errors")
            TypeError: Can we see errors
            <BLANKLINE>
            <BLANKLINE>
            **********************************************************************
            Can't post-mortem debug when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_error2 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_error2
                raise TypeError("I hope so")
            TypeError: I hope so
            <BLANKLINE>
            <BLANKLINE>
            **********************************************************************
            Can't post-mortem debug when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_fail1 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_fail1
                self.assertEqual(1, 2)
            AssertionError: 1 != 2
            <BLANKLINE>
            <BLANKLINE>
            **********************************************************************
            Can't post-mortem debug when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_fail2 (sample3.sampletests_ntd.TestSomething)
            Traceback (most recent call last):
             testrunner-ex/sample3/sampletests_ntd.py", Line NNN, in test_fail2
                self.assertEqual(1, 3)
            AssertionError: 1 != 3
            <BLANKLINE>
            <BLANKLINE>
            **********************************************************************
            Can't post-mortem debug when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
              Ran 6 tests with 0 failures, 4 errors and 0 skipped in N.NNN seconds.
              Tear down sample3.sampletests_ntd.Layer ... not supported
            Total: 8 tests, 0 failures, 4 errors and 0 skipped in N.NNN seconds.
            True
        
        Similarly, pdb.set_trace doesn't work when running tests in a layer
        that is run as a subprocess:
        
            >>> sys.argv = [testrunner_script, '--tests-pattern', 'sampletests_ntds']
            >>> testrunner.run_internal(defaults)
            Running sample1.sampletests_ntds.Layer tests:
              Set up sample1.sampletests_ntds.Layer in 0.000 seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Running sample2.sampletests_ntds.Layer tests:
              Tear down sample1.sampletests_ntds.Layer ... not supported
              Running in a subprocess.
              Set up sample2.sampletests_ntds.Layer in 0.000 seconds.
            --Return--
            > testrunner-ex/sample2/sampletests_ntds.py(37)test_something()->None
            -> import pdb; pdb.set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > testrunner-ex/sample2/sampletests_ntds.py(40)test_something2()->None
            -> import pdb; pdb.set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > testrunner-ex/sample2/sampletests_ntds.py(43)test_something3()->None
            -> import pdb; pdb.set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > testrunner-ex/sample2/sampletests_ntds.py(46)test_something4()->None
            -> import pdb; pdb.set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > testrunner-ex/sample2/sampletests_ntds.py(52)f()->None
            -> import pdb; pdb.set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > doctest.py(351)set_trace()->None
            -> Pdb().set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
            --Return--
            > doctest.py(351)set_trace()->None
            -> Pdb().set_trace()
            (Pdb) c
            <BLANKLINE>
            **********************************************************************
            Can't use pdb.set_trace when running a layer as a subprocess!
            **********************************************************************
            <BLANKLINE>
              Ran 7 tests with 0 failures, 0 errors and 0 skipped in 0.008 seconds.
              Tear down sample2.sampletests_ntds.Layer ... not supported
            Total: 8 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        If you want to use pdb from a test in a layer that is run as a
        subprocess, then rerun the test runner selecting *just* that layer so
        that it's not run as a subprocess.
        
        
        If a test is run in a subprocess and it generates output on stderr (as
        stderrtest does), the output is ignored (but it doesn't cause a SubprocessError
        like it once did).
        
            >>> from six import StringIO
            >>> real_stderr = sys.stderr
            >>> sys.stderr = StringIO()
        
            >>> sys.argv = [testrunner_script, '-s', 'sample2', '--tests-pattern',
            ...     '(sampletests_ntd$|stderrtest)']
            >>> testrunner.run_internal(defaults)
            Running sample2.sampletests_ntd.Layer tests:
              Set up sample2.sampletests_ntd.Layer in 0.000 seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Running sample2.stderrtest.Layer tests:
              Tear down sample2.sampletests_ntd.Layer ... not supported
              Running in a subprocess.
              Set up sample2.stderrtest.Layer in 0.000 seconds.
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.002 seconds.
              Tear down sample2.stderrtest.Layer in 0.000 seconds.
            Total: 2 tests, 0 failures, 0 errors and 0 skipped in 0.197 seconds.
            False
        
            >>> print((sys.stderr.getvalue()))
            A message on stderr.  Please ignore (expected in test output).
        
            >>> sys.stderr = real_stderr
        
        
        
        Egg Support
        ===========
        
        
        The `ftest` Setup Command
        -------------------------
        
        The `ftest` class is a proper `distutils` command and `zope.testrunner`
        exposes it as such via an entry point.
        
          >>> import pkg_resources
          >>> ws = pkg_resources.WorkingSet()
          >>> eps = dict([(ep.name, ep)
          ...             for ep in ws.iter_entry_points('distutils.commands')])
          >>> 'ftest' in eps
          True
          >>> eps['ftest']
          EntryPoint.parse('ftest = zope.testrunner.eggsupport:ftest')
        
        Let's now run this command:
        
          >>> import zope.testrunner
          >>> org_run = zope.testrunner.run
        
          >>> def run(args):
          ...     print(' '.join(args))
          >>> zope.testrunner.run = run
        
          >>> import os, tempfile, shutil
          >>> tmpdir = tempfile.mkdtemp()
          >>> srcdir = os.path.join(tmpdir, 'src')
          >>> os.mkdir(srcdir)
        
          >>> import setuptools.dist
          >>> dist = setuptools.dist.Distribution(
          ...     {'package_dir': {'': srcdir},
          ...      'script_name': __file__})
        
          >>> from zope.testrunner.eggsupport import ftest
          >>> ftest(dist).run()
          IGNORE_ME --test-path .../src
        
        Cleanup:
        
          >>> zope.testrunner.run = org_run
          >>> shutil.rmtree(tmpdir)
        
        
        Skipping Tests with Layers
        --------------------------
        
        The ``SkipLayers`` scanning test loader can replace the standard test loader,
        so that any tests that require layers are skipped. This is necessary, since
        the standard setuptools testing facility does not handle layers. It can be
        used as follows::
        
              setup(
              ...
              setup_requires=['eggtestinfo' # captures testing metadata in EGG-INFO
                             ],
              tests_require=['zope.testrunner',
                            ],
              ...
              test_loader='zope.testrunner.eggsupport:SkipLayers',
              ...
              )
        
        Let's now crete some test suites to make sure that all tests with layers are
        properly skipped.
        
          >>> import doctest
          >>> import unittest
        
          >>> all = unittest.TestSuite()
          >>> class T1(unittest.TestCase):
          ...     def test_t1(self):
          ...         pass
          >>> class T2(unittest.TestCase):
          ...     layer = 'layer'
          ...     def test_t2(self):
          ...         pass
          >>> T3 = doctest.DocTestSuite('zope.testrunner.find')
          >>> T4 = doctest.DocTestSuite('zope.testrunner.options')
          >>> T4.layer = 'layer'
          >>> T5 = doctest.DocFileSuite('testrunner.txt', package='zope.testrunner.tests')
          >>> T6 = doctest.DocFileSuite('testrunner-gc.txt', package='zope.testrunner.tests')
          >>> T6.layer = 'layer'
        
          >>> all = unittest.TestSuite((
          ...     unittest.makeSuite(T1), unittest.makeSuite(T2), T3, T4, T5, T6,
          ...     ))
        
        Let's return those tests from the scan:
        
          >>> from setuptools.command.test import ScanningLoader
          >>> orig_loadTestsFromModule = ScanningLoader.loadTestsFromModule
          >>> ScanningLoader.loadTestsFromModule = lambda *args: all
        
        Now we can retrieve the modules from the layer skipping loader:
        
          >>> from zope.testrunner.eggsupport import SkipLayers
          >>> filtered = SkipLayers().loadTestsFromModule('zope.testrunner')
        
          >>> len(filtered._tests)
          3
          >>> from pprint import pprint
          >>> pprint(filtered._tests)
          [<...T1 testMethod=test_t1>,
           StartUpFailure (zope.testrunner.find),
           .../zope/testrunner/tests/testrunner.txt]
        
        Cleanup:
        
          >>> ScanningLoader.loadTestsFromModule = orig_loadTestsFromModule
        
        When the distribution specified a ``test_suite``, another method is used to
        load the tests.
        
          >>> orig_loadTestsFromNames = ScanningLoader.loadTestsFromNames
          >>> ScanningLoader.loadTestsFromNames = lambda *args: all
        
        Now we can retrieve the modules from the layer skipping loader:
        
          >>> from zope.testrunner.eggsupport import SkipLayers
          >>> filtered = SkipLayers().loadTestsFromNames(
          ...     'zope.testrunner.tests.test_suite', 'zope.testrunner')
        
          >>> len(filtered._tests)
          3
          >>> from pprint import pprint
          >>> pprint(filtered._tests)
          [<...T1 testMethod=test_t1>,
           StartUpFailure (zope.testrunner.find),
           .../zope/testrunner/tests/testrunner.txt]
        
        Cleanup:
        
          >>> ScanningLoader.loadTestsFromNames = orig_loadTestsFromNames
        
        Code Coverage
        =============
        
        If the --coverage option is used, test coverage reports will be generated.  The
        directory name given as the parameter will be used to hold the reports.
        
        
            >>> import os.path, sys, tempfile
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> tempdir = tempfile.mkdtemp(prefix='zope.testrunner-')
            >>> coverage_dir = os.path.join(tempdir, 'coverage_dir')
        
            >>> sys.argv = ['test', '--coverage', coverage_dir]
        
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer11 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.125 seconds.
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer111 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.125 seconds.
            Running samplelayers.Layer112 tests:
              Tear down samplelayers.Layer111 in 0.000 seconds.
              Set up samplelayers.Layer112 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.125 seconds.
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer112 in 0.000 seconds.
              Tear down samplelayers.Layerx in 0.000 seconds.
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.140 seconds.
            Running samplelayers.Layer121 tests:
              Set up samplelayers.Layer121 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.125 seconds.
            Running samplelayers.Layer122 tests:
              Tear down samplelayers.Layer121 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.125 seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
              Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in 0.687 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
            lines   cov%   module   (path)
            ...
               48   100%   sampletests.test1   (testrunner-ex/sampletests/test1.py)
               74   100%   sampletests.test11   (testrunner-ex/sampletests/test11.py)
               74   100%   sampletests.test111   (testrunner-ex/sampletests/test111.py)
               76   100%   sampletests.test112   (testrunner-ex/sampletests/test112.py)
               74   100%   sampletests.test12   (testrunner-ex/sampletests/test12.py)
               74   100%   sampletests.test121   (testrunner-ex/sampletests/test121.py)
               74   100%   sampletests.test122   (testrunner-ex/sampletests/test122.py)
               48   100%   sampletests.test_one   (testrunner-ex/sampletests/test_one.py)
              112    95%   sampletestsf   (testrunner-ex/sampletestsf.py)
            Total: 321 tests, 0 failures, 0 errors and 0 skipped in 0.630 seconds.
            False
        
        The directory specified with the --coverage option will have been created and
        will hold the coverage reports.
        
            >>> os.path.exists(coverage_dir)
            True
            >>> os.listdir(coverage_dir)
            [...]
        
        (We should clean up after ourselves.)
        
            >>> import shutil
            >>> shutil.rmtree(tempdir)
        
        
        Ignoring Tests
        --------------
        
        The ``trace`` module supports ignoring directories and modules based the test
        selection. Only directories selected for testing should report coverage. The
        test runner provides a custom implementation of the relevant API.
        
        The ``TestIgnore`` class, the class managing the ignoring, is initialized by
        passing the command line options. It uses the options to determine the
        directories that should be covered.
        
          >>> class FauxOptions(object):
          ...   package = None
          ...   test_path = [('/myproject/src/blah/foo', ''),
          ...                ('/myproject/src/blah/bar', '')]
          >>> from zope.testrunner import coverage
          >>> from zope.testrunner.find import test_dirs
          >>> ignore = coverage.TestIgnore(test_dirs(FauxOptions(), {}))
          >>> ignore._test_dirs
          ['/myproject/src/blah/foo/', '/myproject/src/blah/bar/']
        
        We can now ask whether a particular module should be ignored:
        
          >>> ignore.names('/myproject/src/blah/foo/baz.py', 'baz')
          False
          >>> ignore.names('/myproject/src/blah/bar/mine.py', 'mine')
          False
          >>> ignore.names('/myproject/src/blah/foo/__init__.py', 'foo')
          False
          >>> ignore.names('/myproject/src/blah/hello.py', 'hello')
          True
        
        When running the test runner, modules are sometimes created from text
        strings. Those should *always* be ignored:
        
          >>> ignore.names('/myproject/src/blah/hello.txt', '<string>')
          True
        
        To make this check fast, the class implements a cache. In an early
        implementation, the result was cached by the module name, which was a problem,
        since a lot of modules carry the same name (not the Python dotted name
        here!). So just because a module has the same name in an ignored and tested
        directory, does not mean it is always ignored:
        
          >>> ignore.names('/myproject/src/blah/module.py', 'module')
          True
          >>> ignore.names('/myproject/src/blah/foo/module.py', 'module')
          False
        
        Profiling
        =========
        The testrunner supports hotshot and cProfile profilers. Hotshot profiler
        support does not work with python2.6
        
            >>> import os.path, sys, tempfile
            >>> profiler = '--profile=hotshot'
            >>> if sys.hexversion >= 0x02060000:
            ...     profiler = '--profile=cProfile'
        
        The testrunner includes the ability to profile the test execution with hotshot
        via the --profile option, if it a python <= 2.6
        
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> sys.path.append(directory_with_tests)
        
            >>> tempdir = tempfile.mkdtemp(prefix='zope.testrunner-')
        
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     '--profile-directory', tempdir,
            ...     ]
        
            >>> sys.argv = [testrunner_script, profiler]
        
        When the tests are run, we get profiling output.
        
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer1 tests:
            ...
            Running samplelayers.Layer11 tests:
            ...
            Running zope.testrunner.layer.UnitTests tests:
            ...
               ncalls  tottime  percall  cumtime  percall filename:lineno(function)
            ...
            Total: ... tests, 0 failures, 0 errors and 0 skipped in ... seconds.
            False
        
        Profiling also works across layers.
        
            >>> sys.argv = [testrunner_script, '-ssample2', profiler,
            ...             '--tests-pattern', 'sampletests_ntd']
            >>> testrunner.run_internal(defaults)
            Running...
              Tear down ... not supported...
               ncalls  tottime  percall  cumtime  percall filename:lineno(function)...
        
        The testrunner creates temnporary files containing hotshot profiler
        data:
        
            >>> os.listdir(tempdir)
            ['tests_profile.cZj2jt.prof', 'tests_profile.yHD-so.prof']
        
        It deletes these when rerun.  We'll delete these ourselves:
        
            >>> import shutil
            >>> shutil.rmtree(tempdir)
        
        Running Without Source Code
        ===========================
        
        The ``--usecompiled`` option allows running tests in a tree without .py
        source code, provided compiled .pyc or .pyo files exist (without
        ``--usecompiled``, .py files are necessary).
        
        We have a very simple directory tree, under ``usecompiled/``, to test
        this.  Because we're going to delete its .py files, we want to work
        in a copy of that:
        
            >>> import os.path, shutil, sys, tempfile
            >>> directory_with_tests = tempfile.mkdtemp()
        
            >>> NEWNAME = "unlikely_package_name"
            >>> src = os.path.join(this_directory, 'testrunner-ex', 'usecompiled')
            >>> os.path.isdir(src)
            True
            >>> dst = os.path.join(directory_with_tests, NEWNAME)
            >>> os.path.isdir(dst)
            False
        
        Have to use our own copying code, to avoid copying read-only SVN files that
        can't be deleted later.
        
            >>> n = len(src) + 1
            >>> for root, dirs, files in os.walk(src):
            ...     dirs[:] = [d for d in dirs if d == "package"] # prune cruft
            ...     os.mkdir(os.path.join(dst, root[n:]))
            ...     for f in files:
            ...         _ = shutil.copy(os.path.join(root, f),
            ...                         os.path.join(dst, root[n:], f))
        
        Now run the tests in the copy:
        
            >>> from zope import testrunner
        
            >>> mydefaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^compiletest$',
            ...     '--package', NEWNAME,
            ...     '-vv',
            ...     ]
            >>> sys.argv = ['test']
            >>> testrunner.run_internal(mydefaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test1 (unlikely_package_name.compiletest.Test)
             test2 (unlikely_package_name.compiletest.Test)
             test1 (unlikely_package_name.package.compiletest.Test)
             test2 (unlikely_package_name.package.compiletest.Test)
              Ran 4 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        If we delete the source files, it's normally a disaster:  the test runner
        doesn't believe any test files, or even packages, exist.  Note that we pass
        ``--keepbytecode`` this time, because otherwise the test runner would
        delete the compiled Python files too:
        
            >>> for root, dirs, files in os.walk(dst):
            ...    for f in files:
            ...        if f.endswith(".py"):
            ...            os.remove(os.path.join(root, f))
            >>> testrunner.run_internal(mydefaults, ["test", "--keepbytecode"])
            Running tests at level 1
            Total: 0 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        Finally, passing ``--usecompiled`` asks the test runner to treat .pyc
        and .pyo files as adequate replacements for .py files.  Note that the
        output is the same as when running with .py source above.  The absence
        of "removing stale bytecode ..." messages shows that ``--usecompiled``
        also implies ``--keepbytecode``:
        
            >>> if sys.version_info >= (3, 2):
            ...     # PEP-3147: pyc files in __pycache__ directories cannot be
            ...     # imported; legacy source-less imports need to use the legacy
            ...     # layout
            ...     for root, dirs, files in os.walk(dst):
            ...         for f in files:
            ...             if f.endswith((".pyc", ".pyo")):
            ...                 # "root/f" is "dirname/__pycache__/name.magic.ext"
            ...                 dirname = os.path.dirname(os.path.abspath(root))
            ...                 namewmagic, ext = os.path.splitext(os.path.basename(f))
            ...                 newname = os.path.splitext(namewmagic)[0] + ext
            ...                 os.rename(os.path.join(root, f),
            ...                           os.path.join(dirname, newname))
        
            >>> testrunner.run_internal(mydefaults, ["test", "--usecompiled"])
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test1 (unlikely_package_name.compiletest.Test)
             test2 (unlikely_package_name.compiletest.Test)
             test1 (unlikely_package_name.package.compiletest.Test)
             test2 (unlikely_package_name.package.compiletest.Test)
              Ran 4 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Remove the temporary directory:
        
            >>> shutil.rmtree(directory_with_tests)
        
        Repeating Tests
        ===============
        
        The --repeat option can be used to repeat tests some number of times.
        Repeating tests is useful to help make sure that tests clean up after
        themselves.
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test --layer 112 --layer UnitTests --repeat 3'.split()
            >>> from zope import testrunner
            >>> testrunner.run_internal(defaults)
            Running samplelayers.Layer112 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer112 in 0.000 seconds.
            Iteration 1
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.010 seconds.
            Iteration 2
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.010 seconds.
            Iteration 3
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.010 seconds.
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer112 in N.NNN seconds.
              Tear down samplelayers.Layerx in N.NNN seconds.
              Tear down samplelayers.Layer11 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            Iteration 1
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Iteration 2
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Iteration 3
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 182 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        The tests are repeated by layer.  Layers are set up and torn down only
        once.
        
        Garbage Collection Control
        ==========================
        
        When having problems that seem to be caused my memory-management
        errors, it can be helpful to adjust Python's cyclic garbage collector
        or to get garbage colection statistics.  The --gc option can be used
        for this purpose.
        
        If you think you are getting a test failure due to a garbage
        collection problem, you can try disabling garbage collection by
        using the --gc option with a value of zero.
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = ['--path', directory_with_tests]
        
            >>> from zope import testrunner
        
            >>> sys.argv = 'test --tests-pattern ^gc0$ --gc 0 -vv'.split()
            >>> _ = testrunner.run_internal(defaults)
            Cyclic garbage collection is disabled.
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             make_sure_gc_is_disabled (gc0)
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        
        Alternatively, if you think you are having a garbage collection
        related problem, you can cause garbage collection to happen more often
        by providing a low threshold:
            
            >>> sys.argv = 'test --tests-pattern ^gc1$ --gc 1 -vv'.split()
            >>> _ = testrunner.run_internal(defaults)
            Cyclic garbage collection threshold set to: (1,)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             make_sure_gc_threshold_is_one (gc1)
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        You can specify up to 3 --gc options to set each of the 3 gc threshold
        values:
        
            
            >>> sys.argv = ('test --tests-pattern ^gcset$ --gc 701 --gc 11 --gc 9 -vv'
            ...             .split())
            >>> _ = testrunner.run_internal(defaults)
            Cyclic garbage collection threshold set to: (701, 11, 9)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             make_sure_gc_threshold_is_701_11_9 (gcset)
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        Specifying more than 3 --gc options is not allowed:
        
        
            >>> from six import StringIO
            >>> out = StringIO()
            >>> stdout = sys.stdout
            >>> sys.stdout = out
        
            >>> sys.argv = ('test --tests-pattern ^gcset$ --gc 701 --gc 42 --gc 11 --gc 9 -vv'
            ...             .split())
            >>> _ = testrunner.run_internal(defaults)
            Traceback (most recent call last):
            ...
            SystemExit: 1
        
            >>> sys.stdout = stdout
        
            >>> print(out.getvalue())
            Too many --gc options
        
        Garbage Collection Statistics
        -----------------------------
        
        You can enable gc debugging statistics using the --gc-options (-G)
        option.  You should provide names of one or more of the flags
        described in the library documentation for the gc module.
        
        The output statistics are written to standard error.
        
            >>> from six import StringIO
            >>> err = StringIO()
            >>> stderr = sys.stderr
            >>> sys.stderr = err
            >>> sys.argv = ('test --tests-pattern ^gcstats$ -G DEBUG_STATS'
            ...             ' -G DEBUG_COLLECTABLE -vv'
            ...             .split())
            >>> _ = testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             generate_some_gc_statistics (gcstats)
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
            >>> sys.stderr = stderr
        
            >>> print(err.getvalue())        # doctest: +ELLIPSIS
            gc: collecting generation ...
        
        
        Debugging Memory Leaks
        ======================
        
        The --report-refcounts (-r) option can be used with the --repeat (-N)
        option to detect and diagnose memory leaks.  To use this option, you
        must configure Python with the --with-pydebug option. (On Unix, pass
        this option to configure and then build Python.)
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> from zope import testrunner
            
            >>> sys.argv = 'test --layer Layer11$ --layer Layer12$ -N4 -r'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer11 in 0.000 seconds.
            Iteration 1
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.013 seconds.
            Iteration 2
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.012 seconds.
              sys refcount=100401   change=0     
            Iteration 3
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.012 seconds.
              sys refcount=100401   change=0     
            Iteration 4
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.013 seconds.
              sys refcount=100401   change=0     
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
            Iteration 1
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.013 seconds.
            Iteration 2
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.012 seconds.
              sys refcount=100411   change=0     
            Iteration 3
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.012 seconds.
              sys refcount=100411   change=0     
            Iteration 4
              Ran 26 tests with 0 failures, 0 errors and 0 skipped in 0.012 seconds.
              sys refcount=100411   change=0     
            Tearing down left over layers:
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            Total: 68 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
        
        Each layer is repeated the requested number of times.  For each
        iteration after the first, the system refcount and change in system
        refcount is shown. The system refcount is the total of all refcount in
        the system.  When a refcount on any object is changed, the system
        refcount is changed by the same amount.  Tests that don't leak show
        zero changes in systen refcount.
        
        Let's look at an example test that leaks:
        
            >>> sys.argv = 'test --tests-pattern leak -N4 -r'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:...
            Iteration 1
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Iteration 2
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sys refcount=92506    change=12
            Iteration 3
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sys refcount=92513    change=12
            Iteration 4
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sys refcount=92520    change=12
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        Here we see that the system refcount is increating.  If we specify a
        verbosity greater than one, we can get details broken out by object
        type (or class):
        
            >>> sys.argv = 'test --tests-pattern leak -N5 -r -v'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:...
            Iteration 1
              Running:
                .
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Iteration 2
              Running:
                .
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sum detail refcount=95832    sys refcount=105668   change=16    
                Leak details, changes in instances and refcounts by type/class:
                type/class                                               insts   refs
                -------------------------------------------------------  -----   ----
                classobj                                                     0      1
                dict                                                         2      2
                float                                                        1      1
                int                                                          2      2
                leak.ClassicLeakable                                         1      1
                leak.Leakable                                                1      1
                str                                                          0      4
                tuple                                                        1      1
                type                                                         0      3
                -------------------------------------------------------  -----   ----
                total                                                        8     16
            Iteration 3
              Running:
                .
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sum detail refcount=95844    sys refcount=105680   change=12    
                Leak details, changes in instances and refcounts by type/class:
                type/class                                               insts   refs
                -------------------------------------------------------  -----   ----
                classobj                                                     0      1
                dict                                                         2      2
                float                                                        1      1
                int                                                         -1      0
                leak.ClassicLeakable                                         1      1
                leak.Leakable                                                1      1
                str                                                          0      4
                tuple                                                        1      1
                type                                                         0      1
                -------------------------------------------------------  -----   ----
                total                                                        5     12
            Iteration 4
              Running:
                .
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sum detail refcount=95856    sys refcount=105692   change=12    
                Leak details, changes in instances and refcounts by type/class:
                type/class                                               insts   refs
                -------------------------------------------------------  -----   ----
                classobj                                                     0      1
                dict                                                         2      2
                float                                                        1      1
                leak.ClassicLeakable                                         1      1
                leak.Leakable                                                1      1
                str                                                          0      4
                tuple                                                        1      1
                type                                                         0      1
                -------------------------------------------------------  -----   ----
                total                                                        6     12
            Iteration 5
              Running:
                .
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
              sum detail refcount=95868    sys refcount=105704   change=12    
                Leak details, changes in instances and refcounts by type/class:
                type/class                                               insts   refs
                -------------------------------------------------------  -----   ----
                classobj                                                     0      1
                dict                                                         2      2
                float                                                        1      1
                leak.ClassicLeakable                                         1      1
                leak.Leakable                                                1      1
                str                                                          0      4
                tuple                                                        1      1
                type                                                         0      1
                -------------------------------------------------------  -----   ----
                total                                                        6     12
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        It is instructive to analyze the results in some detail.  The test
        being run was designed to intentionally leak:
        
            class ClassicLeakable:
                def __init__(self):
                    self.x = 'x'
        
            class Leakable(object):
                def __init__(self):
                    self.x = 'x'
        
            leaked = []
        
            class TestSomething(unittest.TestCase):
        
                def testleak(self):
                    leaked.append((ClassicLeakable(), Leakable(), time.time()))
        
        Let's go through this by type.
        
        float, leak.ClassicLeakable, leak.Leakable, and tuple
            We leak one of these every time.  This is to be expected because
            we are adding one of these to the list every time.
        
        str
            We don't leak any instances, but we leak 4 references. These are
            due to the instance attributes avd values.
        
        dict
            We leak 2 of these, one for each ClassicLeakable and Leakable
            instance. 
        
        classobj
            We increase the number of classobj instance references by one each
            time because each ClassicLeakable instance has a reference to its
            class.  This instances increases the references in it's class,
            which increases the total number of references to classic classes
            (clasobj instances).
        
        type
            For most interations, we increase the number of type references by
            one for the same reason we increase the number of clasobj
            references by one.  The increase of the number of type references
            by 3 in the second iteration is puzzling, but illustrates that
            this sort of data is often puzzling.
        
        int
            The change in the number of int instances and references in this
            example is a side effect of the statistics being gathered.  Lots
            of integers are created to keep the memory statistics used here.
        
        The summary statistics include the sum of the detail refcounts.  (Note
        that this sum is less than the system refcount.  This is because the
        detailed analysis doesn't inspect every object. Not all objects in the
        system are returned by sys.getobjects.)
        
        Knitting in extra package directories
        =====================================
        
        Python packages have __path__ variables that can be manipulated to add
        extra directories cntaining software used in the packages.  The
        testrunner needs to be given extra information about this sort of
        situation.
        
        Let's look at an example.  The testrunner-ex-knit-lib directory
        is a directory that we want to add to the Python path, but that we
        don't want to search for tests.  It has a sample4 package and a
        products subpackage.  The products subpackage adds the
        testrunner-ex-knit-products to it's __path__.  We want to run tests
        from the testrunner-ex-knit-products directory.  When we import these
        tests, we need to import them from the sample4.products package.  We
        can't use the --path option to name testrunner-ex-knit-products.
        It isn't enough to add the containing directory to the test path
        because then we wouldn't be able to determine the package name
        properly.  We might be able to use the --package option to run the
        tests from the sample4/products package, but we want to run tests in
        testrunner-ex that aren't in this package.  
        
        We can use the --package-path option in this case.  The --package-path
        option is like the --test-path option in that it defines a path to be
        searched for tests without affecting the python path.  It differs in
        that it supplied a package name that is added a profex when importing
        any modules found.  The --package-path option takes *two* arguments, a
        package name and file path.
        
            >>> import os.path, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> sys.path.append(os.path.join(this_directory, 'testrunner-ex-pp-lib'))
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     '--package-path',
            ...     os.path.join(this_directory, 'testrunner-ex-pp-products'),
            ...     'sample4.products',
            ...     ]
        
            >>> from zope import testrunner
            
            >>> sys.argv = 'test --layer Layer111 -vv'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer111 in 0.000 seconds.
              Running:
                test_x1 (sample1.sampletests.test111.TestA)
                test_y0 (sample1.sampletests.test111.TestA)
                ...
                test_y0 (sampletests.test111)
                test_z1 (sampletests.test111)
                testrunner-ex/sampletests/../sampletestsl.txt
                test_extra_test_in_products (sample4.products.sampletests.Test)
                test_another_test_in_products (sample4.products.more.sampletests.Test)
              Ran 28 tests with 0 failures, 0 errors and 0 skipped in 0.008 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer111 in 0.000 seconds.
              Tear down samplelayers.Layerx in 0.000 seconds.
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
        
        In the example, the last test, test_extra_test_in_products, came from
        the products directory.  As usual, we can select the knit-in packages
        or individual packages within knit-in packages:
        
            >>> sys.argv = 'test --package sample4.products -vv'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer111 in 0.000 seconds.
              Running:
                test_extra_test_in_products (sample4.products.sampletests.Test)
                test_another_test_in_products (sample4.products.more.sampletests.Test)
              Ran 2 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer111 in 0.000 seconds.
              Tear down samplelayers.Layerx in 0.000 seconds.
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
        
            >>> sys.argv = 'test --package sample4.products.more -vv'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer1 in 0.000 seconds.
              Set up samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer111 in 0.000 seconds.
              Running:
                test_another_test_in_products (sample4.products.more.sampletests.Test)
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer111 in 0.000 seconds.
              Tear down samplelayers.Layerx in 0.000 seconds.
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
        
        
        testrunner Edge Cases
        =====================
        
        This document has some edge-case examples to test various aspects of
        the test runner.
        
        Separating Python path and test directories
        -------------------------------------------
        
        The --path option defines a directory to be searched for tests *and* a
        directory to be added to Python's search path.  The --test-path option
        can be used when you want to set a test search path without also
        affecting the Python path:
        
            >>> import os, sys
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
        
            >>> from zope import testrunner
        
            >>> defaults = [
            ...     '--test-path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
            >>> sys.argv = ['test']
            >>> testrunner.run_internal(defaults)
            ... # doctest: +ELLIPSIS
            Test-module import failures:
            <BLANKLINE>
            Module: sampletestsf
            <BLANKLINE>
            Traceback (most recent call last):
            ImportError: No module named sampletestsf
            ...
        
            >>> sys.path.append(directory_with_tests)
            >>> sys.argv = ['test']
            >>> testrunner.run_internal(defaults)
            ... # doctest: +ELLIPSIS
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            ...
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 156 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 321 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            False
        
        Bug #251759: The test runner's protection against descending into non-package
        directories was ineffective, e.g. picking up tests from eggs that were stored
        close by:
        
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex-251759')
        
            >>> defaults = [
            ...     '--test-path', directory_with_tests,
            ...     ]
            >>> testrunner.run_internal(defaults)
            Total: 0 tests, 0 failures, 0 errors and 0 skipped in 0.000 seconds.
            False
        
        
        Debugging Edge Cases
        --------------------
        
            >>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
            >>> defaults = [
            ...     '--test-path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
            >>> class Input:
            ...     def __init__(self, src):
            ...         self.lines = src.split('\n')
            ...     def readline(self):
            ...         line = self.lines.pop(0)
            ...         print(line)
            ...         return line+'\n'
        
            >>> real_stdin = sys.stdin
        
        Using pdb.set_trace in a function called by an ordinary test:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace2').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +ELLIPSIS
            Running zope.testrunner.layer.UnitTests tests:...
            > testrunner-ex/sample3/sampletests_d.py(47)f()
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
            ...
            False
        
        Using pdb.set_trace in a function called by a doctest in a doc string:
        
            >>> sys.stdin = Input('n\np x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace4').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            > testrunner-ex/sample3/sampletests_d.py(NNN)f()
            -> y = x
            (Pdb) n
            --Return--
            > ...->None
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Using pdb in a docstring-based doctest
        
            >>> sys.stdin = Input('n\np x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace3').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            > <doctest sample3.sampletests_d.set_trace3[1]>(3)?()
            -> y = x
            (Pdb) n
            --Return--
            > ...->None
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Using pdb.set_trace in a doc file:
        
        
            >>> sys.stdin = Input('n\np x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace5').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            > <doctest set_trace5.txt[1]>(3)?()
            -> y = x
            (Pdb) n
            --Return--
            > ...->None
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Using pdb.set_trace in a function called by a doctest in a doc file:
        
        
            >>> sys.stdin = Input('n\np x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t set_trace6').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            > testrunner-ex/sample3/sampletests_d.py(NNN)f()
            -> y = x
            (Pdb) n
            --Return--
            > ...->None
            -> y = x
            (Pdb) p x
            1
            (Pdb) c
              Ran 1 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Post-mortem debugging function called from ordinary test:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem2 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:...
            <BLANKLINE>
            <BLANKLINE>
            Error in test test_post_mortem2 (sample3.sampletests_d.TestSomething)
            Traceback (most recent call last):
              File "testrunner-ex/sample3/sampletests_d.py",
                   line 37, in test_post_mortem2
                g()
              File "testrunner-ex/sample3/sampletests_d.py", line 46, in g
                raise ValueError
            ValueError
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(46)g()
            -> raise ValueError
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Post-mortem debugging docstring-based doctest:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem3 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error in test post_mortem3 (sample3.sampletests_d)
            Traceback (most recent call last):
            ...UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (2 examples)>
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > <doctest sample3.sampletests_d.post_mortem3[1]>(1)?()
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Post-mortem debugging function called from docstring-based doctest:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem4 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error in test post_mortem4 (sample3.sampletests_d)
            Traceback (most recent call last):
            ...UnexpectedException: testrunner-ex/sample3/sampletests_d.py:NNN (1 example)>
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(NNN)g()
            -> raise ValueError
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Post-mortem debugging file-based doctest:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem5 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error testrunner-ex/sample3/post_mortem5.txt
            Traceback (most recent call last):
            ...UnexpectedException: testrunner-ex/sample3/post_mortem5.txt:0 (2 examples)>
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > <doctest post_mortem5.txt[1]>(1)?()
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        
        Post-mortem debugging function called from file-based doctest:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem6 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:...
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Error testrunner-ex/sample3/post_mortem6.txt
            Traceback (most recent call last):
              File ".../zope/testing/doctest/__init__.py", Line NNN, in debug
                runner.run(self._dt_test, clear_globs=False)
              File ".../zope/testing/doctest/__init__.py", Line NNN, in run
                r = DocTestRunner.run(self, test, compileflags, out, False)
              File ".../zope/testing/doctest/__init__.py", Line NNN, in run
                return self.__run(test, compileflags, out)
              File ".../zope/testing/doctest/__init__.py", Line NNN, in __run
                exc_info)
              File ".../zope/testing/doctest/__init__.py", Line NNN, in report_unexpected_exception
                raise UnexpectedException(test, example, exc_info)
            ...UnexpectedException: testrunner-ex/sample3/post_mortem6.txt:0 (2 examples)>
            <BLANKLINE>
            ...ValueError
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(NNN)g()
            -> raise ValueError
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Post-mortem debugging of a docstring doctest failure:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem_failure2 -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:...
            <BLANKLINE>
            <BLANKLINE>
            Error in test post_mortem_failure2 (sample3.sampletests_d)
            <BLANKLINE>
            File "testrunner-ex/sample3/sampletests_d.py",
                           line 81, in sample3.sampletests_d.post_mortem_failure2
            <BLANKLINE>
            x
            <BLANKLINE>
            Want:
            2
            <BLANKLINE>
            Got:
            1
            <BLANKLINE>
            <BLANKLINE>
            > testrunner-ex/sample3/sampletests_d.py(81)_()
            ...ValueError: Expected and actual output are different
            > <string>(1)...()
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        
        Post-mortem debugging of a docfile doctest failure:
        
            >>> sys.stdin = Input('p x\nc')
            >>> sys.argv = ('test -ssample3 --tests-pattern ^sampletests_d$'
            ...             ' -t post_mortem_failure.txt -D').split()
            >>> try: testrunner.run_internal(defaults)
            ... finally: sys.stdin = real_stdin
            ... # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:...
            <BLANKLINE>
            <BLANKLINE>
            Error in test /home/jim/z3/zope.testrunner/src/zope/testing/testrunner-ex/sample3/post_mortem_failure.txt
            <BLANKLINE>
            File "testrunner-ex/sample3/post_mortem_failure.txt",
                                              line 2, in post_mortem_failure.txt
            <BLANKLINE>
            x
            <BLANKLINE>
            Want:
            2
            <BLANKLINE>
            Got:
            1
            <BLANKLINE>
            <BLANKLINE>
            > testrunner-ex/sample3/post_mortem_failure.txt(2)_()
            ...ValueError:
            Expected and actual output are different
            > <string>(1)...()
            (Pdb) p x
            1
            (Pdb) c
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Post-mortem debugging with triple verbosity
        
            >>> sys.argv = 'test --layer samplelayers.Layer1$ -vvv -D'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Running:
                test_x1 (sampletestsf.TestA1) (0.000 s)
                test_y0 (sampletestsf.TestA1) (0.000 s)
                test_z0 (sampletestsf.TestA1) (0.000 s)
                test_x0 (sampletestsf.TestB1) (0.000 s)
                test_y1 (sampletestsf.TestB1) (0.000 s)
                test_z0 (sampletestsf.TestB1) (0.000 s)
                test_1 (sampletestsf.TestNotMuch1) (0.000 s)
                test_2 (sampletestsf.TestNotMuch1) (0.000 s)
                test_3 (sampletestsf.TestNotMuch1) (0.000 s)
              Ran 9 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer1 in 0.000 seconds.
            False
        
        Test Suites with None for suites or tests
        -----------------------------------------
        
            >>> sys.argv = ['test',
            ...             '--tests-pattern', '^sampletests_none_suite$',
            ...     ]
            >>> testrunner.run_internal(defaults)
            Test-module import failures:
            <BLANKLINE>
            Module: sample1.sampletests_none_suite
            <BLANKLINE>
            Traceback (most recent call last):
            TypeError: Invalid test_suite, None, in sample1.sampletests_none_suite
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Test-modules with import problems:
              sample1.sampletests_none_suite
            Total: 0 tests, 0 failures, 1 errors and 0 skipped in N.NNN seconds.
            True
        
        
            >>> sys.argv = ['test',
            ...             '--tests-pattern', '^sampletests_none_test$',
            ...     ]
            >>> testrunner.run_internal(defaults)
            Test-module import failures:
            <BLANKLINE>
            Module: sample1.sampletests_none_test
            <BLANKLINE>
            Traceback (most recent call last):
            TypeError: ...
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Test-modules with import problems:
              sample1.sampletests_none_test
            Total: 0 tests, 0 failures, 1 errors and 0 skipped in N.NNN seconds.
            True
        
        You must use --repeat with --report-refcounts
        ---------------------------------------------
        
        It is an error to specify --report-refcounts (-r) without specifying a
        repeat count greater than 1
        
            >>> sys.argv = 'test -r'.split()
            >>> testrunner.run_internal(defaults)
                    You must use the --repeat (-N) option to specify a repeat
                    count greater than 1 when using the --report_refcounts (-r)
                    option.
            <BLANKLINE>
            True
        
            >>> sys.argv = 'test -r -N1'.split()
            >>> testrunner.run_internal(defaults)
                    You must use the --repeat (-N) option to specify a repeat
                    count greater than 1 when using the --report_refcounts (-r)
                    option.
            <BLANKLINE>
            True
        
        
        Selection
        ---------
        
        Several tests can be excluded using the '!' notation:
        
            >>> sys.argv = 'test -u -vv -ssample1.sample13 -t!test_x -t!test_y'.split()
            >>> testrunner.run_internal(defaults)
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
             test_z0 (sample1.sample13.sampletests.TestA)
             test_z0 (sample1.sample13.sampletests.TestB)
             test_1 (sample1.sample13.sampletests.TestNotMuch)
             test_2 (sample1.sample13.sampletests.TestNotMuch)
             test_3 (sample1.sample13.sampletests.TestNotMuch)
             test_z1 (sample1.sample13.sampletests)
             testrunner-ex/sample1/sample13/../../sampletests.txt
              Ran 7 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            False
        
        Errors and Failures
        ===================
        
        Let's look at tests that have errors and failures, first we need to make a
        temporary copy of the entire testing directory (except .svn files which may
        be read only):
        
            >>> import os.path, sys, tempfile, shutil
            >>> tmpdir = tempfile.mkdtemp()
            >>> directory_with_tests = os.path.join(tmpdir, 'testrunner-ex')
            >>> source = os.path.join(this_directory, 'testrunner-ex')
            >>> n = len(source) + 1
            >>> for root, dirs, files in os.walk(source):
            ...     dirs[:] = [d for d in dirs if d != ".svn"] # prune cruft
            ...     os.mkdir(os.path.join(directory_with_tests, root[n:]))
            ...     for f in files:
            ...         _ = shutil.copy(os.path.join(root, f),
            ...                         os.path.join(directory_with_tests, root[n:], f))
        
            >>> from zope import testrunner
            >>> defaults = [
            ...     '--path', directory_with_tests,
            ...     '--tests-pattern', '^sampletestsf?$',
            ...     ]
        
            >>> sys.argv = 'test --tests-pattern ^sampletests(f|_e|_f)?$ '.split()
            >>> testrunner.run_internal(defaults)
            ... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
            Running samplelayers.Layer1 tests:
            ...
            Running zope.testrunner.layer.UnitTests tests:
            ...
            <BLANKLINE>
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_e)
            Failed doctest test for sample2.sampletests_e.eek
              File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_e.py", line 30, in sample2.sampletests_e.eek
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_e.eek[0]>", line 1, in ?
                    f()
                  File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                    g()
                  File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                    x = y + 1
                   - __traceback_info__: I don't know what Y should be.
                NameError: global name 'y' is not defined
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Error in test test3 (sample2.sampletests_e.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_e.py", line 43, in test3
                f()
              File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                g()
              File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                x = y + 1
               - __traceback_info__: I don't know what Y should be.
            NameError: global name 'y' is not defined
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Failure in test testrunner-ex/sample2/e.txt
            Failed doctest test for e.txt
              File "testrunner-ex/sample2/e.txt", line 0
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/e.txt", line 4, in e.txt
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest e.txt[1]>", line 1, in ?
                    f()
                  File "<doctest e.txt[0]>", line 2, in f
                    return x
                NameError: global name 'x' is not defined
            <BLANKLINE>
            <BLANKLINE>
            <BLANKLINE>
            Failure in test test (sample2.sampletests_f.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_f.py", line 21, in test
                self.assertEqual(1,0)
              File "/usr/local/python/2.3/lib/python2.3/unittest.py", line 302, in failUnlessEqual
                raise self.failureException, \
            AssertionError: 1 != 0
            <BLANKLINE>
              Ran 164 tests with 3 failures, 1 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 329 tests, 3 failures, 1 errors and 0 skipped in N.NNN seconds.
            True
        
        We see that we get an error report and a traceback for the failing
        test.  In addition, the test runner returned True, indicating that
        there was an error.
        
        If we ask for verbosity, the dotted output will be interrupted, and
        there'll be a summary of the errors at the end of the test:
        
            >>> sys.argv = 'test --tests-pattern ^sampletests(f|_e|_f)?$ -uv'.split()
            >>> testrunner.run_internal(defaults)
            ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF
            Running tests at level 1
            Running zope.testrunner.layer.UnitTests tests:
            ...
              Running:
            .................................................................................................
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_e)
            Failed doctest test for sample2.sampletests_e.eek
              File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_e.py", line 30,
                in sample2.sampletests_e.eek
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_e.eek[0]>", line 1, in ?
                    f()
                  File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                    g()
                  File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                    x = y + 1
                   - __traceback_info__: I don't know what Y should be.
                NameError: global name 'y' is not defined
            <BLANKLINE>
            ...
            <BLANKLINE>
            <BLANKLINE>
            Error in test test3 (sample2.sampletests_e.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_e.py", line 43, in test3
                f()
              File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                g()
              File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                x = y + 1
               - __traceback_info__: I don't know what Y should be.
            NameError: global name 'y' is not defined
            <BLANKLINE>
            ...
            <BLANKLINE>
            Failure in test testrunner-ex/sample2/e.txt
            Failed doctest test for e.txt
              File "testrunner-ex/sample2/e.txt", line 0
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/e.txt", line 4, in e.txt
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest e.txt[1]>", line 1, in ?
                    f()
                  File "<doctest e.txt[0]>", line 2, in f
                    return x
                NameError: global name 'x' is not defined
            <BLANKLINE>
            .
            <BLANKLINE>
            Failure in test test (sample2.sampletests_f.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_f.py", line 21, in test
                self.assertEqual(1,0)
              File ".../unittest.py", line 302, in failUnlessEqual
                raise self.failureException, \
            AssertionError: 1 != 0
            <BLANKLINE>
            ................................................................................................
            <BLANKLINE>
              Ran 164 tests with 3 failures, 1 errors and 0 skipped in 0.040 seconds.
            ...
            <BLANKLINE>
            Tests with errors:
               test3 (sample2.sampletests_e.Test)
            <BLANKLINE>
            Tests with failures:
               eek (sample2.sampletests_e)
               testrunner-ex/sample2/e.txt
               test (sample2.sampletests_f.Test)
            True
        
        Similarly for progress output, the progress ticker will be interrupted:
        
            >>> sys.argv = ('test --tests-pattern ^sampletests(f|_e|_f)?$ -u -ssample2'
            ...             ' -p').split()
            >>> testrunner.run_internal(defaults)
            ... # doctest: +NORMALIZE_WHITESPACE +REPORT_NDIFF
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Running:
                1/47 (2.1%)
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_e)
            Failed doctest test for sample2.sampletests_e.eek
              File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_e.py", line 30, in sample2.sampletests_e.eek
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_e.eek[0]>", line 1, in ?
                    f()
                  File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                    g()
                  File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                    x = y + 1
                   - __traceback_info__: I don't know what Y should be.
                NameError: global name 'y' is not defined
            <BLANKLINE>
                2/47 (4.3%)\r
                           \r
                3/47 (6.4%)\r
                           \r
                4/47 (8.5%)
            <BLANKLINE>
            Error in test test3 (sample2.sampletests_e.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_e.py", line 43, in test3
                f()
              File "testrunner-ex/sample2/sampletests_e.py", line 19, in f
                g()
              File "testrunner-ex/sample2/sampletests_e.py", line 24, in g
                x = y + 1
               - __traceback_info__: I don't know what Y should be.
            NameError: global name 'y' is not defined
            <BLANKLINE>
                5/47 (10.6%)\r
                           \r
                6/47 (12.8%)\r
                            \r
                7/47 (14.9%)
            <BLANKLINE>
            Failure in test testrunner-ex/sample2/e.txt
            Failed doctest test for e.txt
              File "testrunner-ex/sample2/e.txt", line 0
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/e.txt", line 4, in e.txt
            Failed example:
                f()
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest e.txt[1]>", line 1, in ?
                    f()
                  File "<doctest e.txt[0]>", line 2, in f
                    return x
                NameError: global name 'x' is not defined
            <BLANKLINE>
                8/47 (17.0%)
            <BLANKLINE>
            Failure in test test (sample2.sampletests_f.Test)
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_f.py", line 21, in test
                self.assertEqual(1,0)
              File ".../unittest.py", line 302, in failUnlessEqual
                raise self.failureException, \
            AssertionError: 1 != 0
            <BLANKLINE>
                9/47 (19.1%)\r
                            \r
                10/47 (21.3%)\r
                             \r
                11/47 (23.4%)\r
                             \r
                12/47 (25.5%)\r
                             \r
                13/47 (27.7%)\r
                             \r
                14/47 (29.8%)\r
                             \r
                15/47 (31.9%)\r
                             \r
                16/47 (34.0%)\r
                             \r
                17/47 (36.2%)\r
                             \r
                18/47 (38.3%)\r
                             \r
                19/47 (40.4%)\r
                             \r
                20/47 (42.6%)\r
                             \r
                21/47 (44.7%)\r
                             \r
                22/47 (46.8%)\r
                             \r
                23/47 (48.9%)\r
                             \r
                24/47 (51.1%)\r
                             \r
                25/47 (53.2%)\r
                             \r
                26/47 (55.3%)\r
                             \r
                27/47 (57.4%)\r
                             \r
                28/47 (59.6%)\r
                             \r
                29/47 (61.7%)\r
                             \r
                30/47 (63.8%)\r
                             \r
                31/47 (66.0%)\r
                             \r
                32/47 (68.1%)\r
                             \r
                33/47 (70.2%)\r
                             \r
                34/47 (72.3%)\r
                             \r
                35/47 (74.5%)\r
                             \r
                36/47 (76.6%)\r
                             \r
                37/47 (78.7%)\r
                             \r
                38/47 (80.9%)\r
                             \r
                39/47 (83.0%)\r
                             \r
                40/47 (85.1%)\r
                             \r
                41/47 (87.2%)\r
                             \r
                42/47 (89.4%)\r
                             \r
                43/47 (91.5%)\r
                             \r
                44/47 (93.6%)\r
                             \r
                45/47 (95.7%)\r
                             \r
                46/47 (97.9%)\r
                             \r
                47/47 (100.0%)\r
                              \r
            <BLANKLINE>
              Ran 47 tests with 3 failures, 1 errors and 0 skipped in 0.054 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            True
        
        If you also want a summary of errors at the end, ask for verbosity as well
        as progress output.
        
        
        Suppressing multiple doctest errors
        -----------------------------------
        
        Often, when a doctest example fails, the failure will cause later
        examples in the same test to fail.  Each failure is reported:
        
            >>> sys.argv = 'test --tests-pattern ^sampletests_1$'.split()
            >>> testrunner.run_internal(defaults) # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_1)
            Failed doctest test for sample2.sampletests_1.eek
              File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 19,
                 in sample2.sampletests_1.eek
            Failed example:
                x = y
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
                    x = y
                NameError: name 'y' is not defined
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 21,
                 in sample2.sampletests_1.eek
            Failed example:
                x
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[1]>", line 1, in ?
                    x
                NameError: name 'x' is not defined
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 24,
                 in sample2.sampletests_1.eek
            Failed example:
                z = x + 1
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[2]>", line 1, in ?
                    z = x + 1
                NameError: name 'x' is not defined
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            True
        
        This can be a bit confusing, especially when there are enough tests
        that they scroll off a screen.  Often you just want to see the first
        failure.  This can be accomplished with the -1 option (for "just show
        me the first failed example in a doctest" :)
        
            >>> sys.argv = 'test --tests-pattern ^sampletests_1$ -1'.split()
            >>> testrunner.run_internal(defaults) # doctest:
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_1)
            Failed doctest test for sample2.sampletests_1.eek
              File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 19,
                 in sample2.sampletests_1.eek
            Failed example:
                x = y
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
                    x = y
                NameError: name 'y' is not defined
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.001 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            True
        
        The --hide-secondary-failures option is an alias for -1:
        
            >>> sys.argv = (
            ...     'test --tests-pattern ^sampletests_1$'
            ...     ' --hide-secondary-failures'
            ...     ).split()
            >>> testrunner.run_internal(defaults) # doctest:
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_1)
            Failed doctest test for sample2.sampletests_1.eek
              File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 19, in sample2.sampletests_1.eek
            Failed example:
                x = y
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
                    x = y
                NameError: name 'y' is not defined
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.001 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            True
        
        The --show-secondary-failures option counters -1 (or it's alias),
        causing the second and subsequent errors to be shown.  This is useful
        if -1 is provided by a test script by inserting it ahead of
        command-line options in sys.argv.
        
            >>> sys.argv = (
            ...     'test --tests-pattern ^sampletests_1$'
            ...     ' --hide-secondary-failures --show-secondary-failures'
            ...     ).split()
            >>> testrunner.run_internal(defaults) # doctest: +NORMALIZE_WHITESPACE
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test eek (sample2.sampletests_1)
            Failed doctest test for sample2.sampletests_1.eek
              File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 19, in sample2.sampletests_1.eek
            Failed example:
                x = y
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
                    x = y
                NameError: name 'y' is not defined
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 21, in sample2.sampletests_1.eek
            Failed example:
                x
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[1]>", line 1, in ?
                    x
                NameError: name 'x' is not defined
            ----------------------------------------------------------------------
            File "testrunner-ex/sample2/sampletests_1.py", line 24, in sample2.sampletests_1.eek
            Failed example:
                z = x + 1
            Exception raised:
                Traceback (most recent call last):
                  File ".../doctest.py", line 1256, in __run
                    compileflags, 1) in test.globs
                  File "<doctest sample2.sampletests_1.eek[2]>", line 1, in ?
                    z = x + 1
                NameError: name 'x' is not defined
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            True
        
        
        Getting diff output for doctest failures
        ----------------------------------------
        
        If a doctest has large expected and actual output, it can be hard to
        see differences when expected and actual output differ.  The --ndiff,
        --udiff, and --cdiff options can be used to get diff output of various
        kinds.
        
            >>> sys.argv = 'test --tests-pattern ^pledge$'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test pledge (pledge)
            Failed doctest test for pledge.pledge
              File "testrunner-ex/pledge.py", line 24, in pledge
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/pledge.py", line 26, in pledge.pledge
            Failed example:
                print_pledge()
            Expected:
                I give my pledge, as an earthling,
                to save, and faithfully, to defend from waste,
                the natural resources of my planet.
                It's soils, minerals, forests, waters, and wildlife.
                <BLANKLINE>
            Got:
                I give my pledge, as and earthling,
                to save, and faithfully, to defend from waste,
                the natural resources of my planet.
                It's soils, minerals, forests, waters, and wildlife.
                <BLANKLINE>
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        Here, the actual output uses the word "and" rather than the word "an",
        but it's a bit hard to pick this out.  We can use the various diff
        outputs to see this better. We could modify the test to ask for diff
        output, but it's easier to use one of the diff options.
        
        The --ndiff option requests a diff using Python's ndiff utility. This
        is the only method that marks differences within lines as well as
        across lines. For example, if a line of expected output contains digit
        1 where actual output contains letter l, a line is inserted with a
        caret marking the mismatching column positions.
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --ndiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test pledge (pledge)
            Failed doctest test for pledge.pledge
              File "testrunner-ex/pledge.py", line 24, in pledge
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/pledge.py", line 26, in pledge.pledge
            Failed example:
                print_pledge()
            Differences (ndiff with -expected +actual):
                - I give my pledge, as an earthling,
                + I give my pledge, as and earthling,
                ?                        +
                  to save, and faithfully, to defend from waste,
                  the natural resources of my planet.
                  It's soils, minerals, forests, waters, and wildlife.
                <BLANKLINE>
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.003 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        The -udiff option requests a standard "unified" diff:
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --udiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test pledge (pledge)
            Failed doctest test for pledge.pledge
              File "testrunner-ex/pledge.py", line 24, in pledge
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/pledge.py", line 26, in pledge.pledge
            Failed example:
                print_pledge()
            Differences (unified diff with -expected +actual):
                @@ -1,3 +1,3 @@
                -I give my pledge, as an earthling,
                +I give my pledge, as and earthling,
                 to save, and faithfully, to defend from waste,
                 the natural resources of my planet.
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        The -cdiff option requests a standard "context" diff:
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --cdiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            <BLANKLINE>
            <BLANKLINE>
            Failure in test pledge (pledge)
            Failed doctest test for pledge.pledge
              File "testrunner-ex/pledge.py", line 24, in pledge
            <BLANKLINE>
            ----------------------------------------------------------------------
            File "testrunner-ex/pledge.py", line 26, in pledge.pledge
            Failed example:
                print_pledge()
            Differences (context diff with expected followed by actual):
                ***************
                *** 1,3 ****
                ! I give my pledge, as an earthling,
                  to save, and faithfully, to defend from waste,
                  the natural resources of my planet.
                --- 1,3 ----
                ! I give my pledge, as and earthling,
                  to save, and faithfully, to defend from waste,
                  the natural resources of my planet.
            <BLANKLINE>
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
        
        Specifying more than one diff option at once causes an error:
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --cdiff --udiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Traceback (most recent call last):
            ...
            SystemExit: 1
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --cdiff --ndiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Traceback (most recent call last):
            ...
            SystemExit: 1
        
            >>> sys.argv = 'test --tests-pattern ^pledge$ --udiff --ndiff'.split()
            >>> _ = testrunner.run_internal(defaults)
            Traceback (most recent call last):
            ...
            SystemExit: 1
        
        
        Testing-Module Import Errors
        ----------------------------
        
        If there are errors when importing a test module, these errors are
        reported.  In order to illustrate a module with a syntax error, we create
        one now:  this module used to be checked in to the project, but then it was
        included in distributions of projects using zope.testrunner too, and distutils
        complained about the syntax error when it compiled Python files during
        installation of such projects.  So first we create a module with bad syntax:
        
            >>> badsyntax_path = os.path.join(directory_with_tests,
            ...                               "sample2", "sampletests_i.py")
            >>> f = open(badsyntax_path, "w")
            >>> print("importx unittest", file=f)  # syntax error
            >>> f.close()
        
        Then run the tests:
        
            >>> sys.argv = ('test --tests-pattern ^sampletests(f|_i)?$ --layer 1 '
            ...            ).split()
            >>> testrunner.run_internal(defaults)
            ... # doctest: +NORMALIZE_WHITESPACE
            Test-module import failures:
            <BLANKLINE>
            Module: sample2.sampletests_i
            <BLANKLINE>
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sampletests_i.py", line 1
                importx unittest
                               ^
            SyntaxError: invalid syntax
            <BLANKLINE>
            <BLANKLINE>
            Module: sample2.sample21.sampletests_i
            <BLANKLINE>
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sample21/sampletests_i.py", line 15, in ?
                import zope.testrunner.huh
            ImportError: No module named huh
            <BLANKLINE>
            <BLANKLINE>
            Module: sample2.sample23.sampletests_i
            <BLANKLINE>
            Traceback (most recent call last):
              File "testrunner-ex/sample2/sample23/sampletests_i.py", line 18, in ?
                class Test(unittest.TestCase):
              File "testrunner-ex/sample2/sample23/sampletests_i.py", line 23, in Test
                raise TypeError('eek')
            TypeError: eek
            <BLANKLINE>
            <BLANKLINE>
            Running samplelayers.Layer1 tests:
              Set up samplelayers.Layer1 in 0.000 seconds.
              Ran 9 tests with 0 failures, 3 errors and 0 skipped in 0.000 seconds.
            Running samplelayers.Layer11 tests:
              Set up samplelayers.Layer11 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.007 seconds.
            Running samplelayers.Layer111 tests:
              Set up samplelayers.Layerx in 0.000 seconds.
              Set up samplelayers.Layer111 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.007 seconds.
            Running samplelayers.Layer112 tests:
              Tear down samplelayers.Layer111 in 0.000 seconds.
              Set up samplelayers.Layer112 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.007 seconds.
            Running samplelayers.Layer12 tests:
              Tear down samplelayers.Layer112 in 0.000 seconds.
              Tear down samplelayers.Layerx in 0.000 seconds.
              Tear down samplelayers.Layer11 in 0.000 seconds.
              Set up samplelayers.Layer12 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.007 seconds.
            Running samplelayers.Layer121 tests:
              Set up samplelayers.Layer121 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.007 seconds.
            Running samplelayers.Layer122 tests:
              Tear down samplelayers.Layer121 in 0.000 seconds.
              Set up samplelayers.Layer122 in 0.000 seconds.
              Ran 26 tests with 0 failures, 3 errors and 0 skipped in 0.006 seconds.
            Tearing down left over layers:
              Tear down samplelayers.Layer122 in 0.000 seconds.
              Tear down samplelayers.Layer12 in 0.000 seconds.
              Tear down samplelayers.Layer1 in 0.000 seconds.
            <BLANKLINE>
            Test-modules with import problems:
              sample2.sampletests_i
              sample2.sample21.sampletests_i
              sample2.sample23.sampletests_i
            Total: 165 tests, 0 failures, 3 errors and 0 skipped in N.NNN seconds.
            True
        
        
        Reporting Errors to Calling Processes
        -------------------------------------
        
        The testrunner returns the error status, indicating that the tests
        failed.  This can be useful for an invoking process that wants to
        monitor the result of a test run.
        
        This is applied when invoking the testrunner using the ``run()`` function
        instead of ``run_internal()``:
        
            >>> sys.argv = (
            ...     'test --tests-pattern ^sampletests_1$'.split())
            >>> try:
            ...     testrunner.run(defaults)
            ... except SystemExit as e:
            ...     print('exited with code', e.code)
            ... else:
            ...     print('sys.exit was not called')
            ... # doctest: +ELLIPSIS
            Running zope.testrunner.layer.UnitTests tests:
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
            ...
              Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.002 seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            exited with code 1
        
        Passing tests exit with code 0 according to UNIX practices:
        
            >>> sys.argv = (
            ...     'test --tests-pattern ^sampletests$'.split())
            >>> try:
            ...     testrunner.run(defaults)
            ... except SystemExit as e2:
            ...     print('exited with code', e2.code)
            ... else:
            ...     print('sys.exit was not called')
            ... # doctest: +ELLIPSIS
            Running samplelayers.Layer11 tests:
            ...
            Running zope.testrunner.layer.UnitTests tests:
              Tear down samplelayers.Layer122 in N.NNN seconds.
              Tear down samplelayers.Layer12 in N.NNN seconds.
              Tear down samplelayers.Layer1 in N.NNN seconds.
              Set up zope.testrunner.layer.UnitTests in N.NNN seconds.
              Ran 130 tests with 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            Tearing down left over layers:
              Tear down zope.testrunner.layer.UnitTests in N.NNN seconds.
            Total: 286 tests, 0 failures, 0 errors and 0 skipped in N.NNN seconds.
            exited with code 0
        
        And remove the temporary directory:
        
            >>> shutil.rmtree(tmpdir)
        
        
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Framework :: Zope3
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing