1- __version__ = "1.0.1 "
1+ __version__ = "1.0.2 "
22
33from datetime import datetime
44from io import StringIO
@@ -92,6 +92,7 @@ class Template_mixin(object):
9292 0 : 'pass' ,
9393 1 : 'fail' ,
9494 2 : 'error' ,
95+ 3 : 'skip' ,
9596 }
9697
9798 DEFAULT_TITLE = 'Unit Test Report'
@@ -293,8 +294,10 @@ class Template_mixin(object):
293294.passClass { background-color: #6c6; }
294295.failClass { background-color: #c60; }
295296.errorClass { background-color: #c00; }
297+ .skipClass { background-color: #ff0; }
296298.passCase { color: #6c6; }
297299.failCase { color: #c60; font-weight: bold; }
300+ .skipCase { color: #ff0; font-weight: bold; }
298301.errorCase { color: #c00; font-weight: bold; }
299302.hiddenRow { display: none; }
300303.testcase { margin-left: 2em; }
@@ -349,6 +352,7 @@ class Template_mixin(object):
349352 <td>Test Group/Test case</td>
350353 <td>Count</td>
351354 <td>Pass</td>
355+ <td>Skip</td>
352356 <td>Fail</td>
353357 <td>Error</td>
354358 <td>View</td>
@@ -358,6 +362,7 @@ class Template_mixin(object):
358362 <td>Total</td>
359363 <td>%(count)s</td>
360364 <td>%(Pass)s</td>
365+ <td>%(skip)s</td>
361366 <td>%(fail)s</td>
362367 <td>%(error)s</td>
363368 <td> </td>
@@ -370,6 +375,7 @@ class Template_mixin(object):
370375 <td>%(desc)s</td>
371376 <td>%(count)s</td>
372377 <td>%(Pass)s</td>
378+ <td>%(skip)s</td>
373379 <td>%(fail)s</td>
374380 <td>%(error)s</td>
375381 <td><a href="javascript:showClassDetail('%(cid)s',%(count)s)">Detail</a></td>
@@ -435,6 +441,7 @@ def __init__(self, verbosity=1):
435441 self .stdout0 = None
436442 self .stderr0 = None
437443 self .success_count = 0
444+ self .skip_count = 0
438445 self .failure_count = 0
439446 self .error_count = 0
440447 self .verbosity = verbosity
@@ -518,6 +525,19 @@ def addFailure(self, test, err):
518525 else :
519526 sys .stderr .write ('F' )
520527
528+ def addSkip (self , test , err ):
529+ self .skip_count += 1
530+ TestResult .addSkip (self , test , err )
531+ _exc_str = self .skipped [- 1 ][1 ]
532+ output = self .complete_output ()
533+ self .result .append ((3 , test , output , _exc_str ))
534+ if self .verbosity > 1 :
535+ sys .stderr .write ('S ' )
536+ sys .stderr .write (str (test ))
537+ sys .stderr .write ('\n ' )
538+ else :
539+ sys .stderr .write ('S' )
540+
521541
522542class HTMLTestRunner (Template_mixin ):
523543 """
@@ -571,6 +591,7 @@ def getReportAttributes(self, result):
571591 duration = str (self .stopTime - self .startTime )
572592 status = []
573593 if result .success_count : status .append ('Pass %s' % result .success_count )
594+ if result .skip_count : status .append ('Skip %s' % result .skip_count )
574595 if result .failure_count : status .append ('Failure %s' % result .failure_count )
575596 if result .error_count : status .append ('Error %s' % result .error_count )
576597 if status :
@@ -627,11 +648,12 @@ def _generate_report(self, result):
627648 sortedResult = self .sortResult (result .result )
628649 for cid , (cls , cls_results ) in enumerate (sortedResult ):
629650 # subtotal for a class
630- np = nf = ne = 0
651+ np = ns = nf = ne = 0
631652 for n ,t ,o ,e in cls_results :
632653 if n == 0 : np += 1
633654 elif n == 1 : nf += 1
634- else : ne += 1
655+ elif n == 2 : ne += 1
656+ elif n == 3 : ns += 1
635657
636658 # format class description
637659 if cls .__module__ == "__main__" :
@@ -642,9 +664,9 @@ def _generate_report(self, result):
642664 desc = doc and '%s: %s' % (name , doc ) or name
643665
644666 row = self .REPORT_CLASS_TMPL % dict (
645- style = ne > 0 and 'errorClass' or nf > 0 and 'failClass' or 'passClass' ,
667+ style = ne > 0 and 'errorClass' or nf > 0 and 'failClass' or ns > 0 and 'skipClass' or 'passClass' ,
646668 desc = desc ,
647- count = np + nf + ne ,
669+ count = np + ns + nf + ne ,
648670 Pass = np ,
649671 fail = nf ,
650672 error = ne ,
@@ -657,8 +679,9 @@ def _generate_report(self, result):
657679
658680 report = self .REPORT_TMPL % dict (
659681 test_list = '' .join (rows ),
660- count = str (result .success_count + result .failure_count + result .error_count ),
682+ count = str (result .success_count + result .failure_count + result .error_count + result . skip_count ),
661683 Pass = str (result .success_count ),
684+ skip = str (result .skip_count ),
662685 fail = str (result .failure_count ),
663686 error = str (result .error_count ),
664687 )
0 commit comments