@@ -3708,7 +3708,10 @@ def _run_transcript_tests(self, transcript_paths: List[str]) -> None:
3708
3708
3709
3709
:param transcript_paths: list of transcript test file paths
3710
3710
"""
3711
+ import time
3711
3712
import unittest
3713
+ import cmd2
3714
+ from colorama import Style
3712
3715
from .transcript import Cmd2TestCase
3713
3716
3714
3717
class TestMyAppCase (Cmd2TestCase ):
@@ -3721,15 +3724,28 @@ class TestMyAppCase(Cmd2TestCase):
3721
3724
self .exit_code = - 1
3722
3725
return
3723
3726
3727
+ verinfo = "." .join (map (str , sys .version_info [:3 ]))
3728
+ num_transcripts = len (transcripts_expanded )
3729
+ plural = '' if len (transcripts_expanded ) == 1 else 's'
3730
+ self .poutput (Style .BRIGHT + utils .center_text ('cmd2 transcript test' , pad = '=' ) + Style .RESET_ALL )
3731
+ self .poutput ('platform {} -- Python {}, cmd2-{}, readline-{}' .format (sys .platform , verinfo , cmd2 .__version__ ,
3732
+ rl_type ))
3733
+ self .poutput ('cwd: {}' .format (os .getcwd ()))
3734
+ self .poutput ('cmd2 app: {}' .format (sys .argv [0 ]))
3735
+ self .poutput (Style .BRIGHT + 'collected {} transcript{}\n ' .format (num_transcripts , plural ) + Style .RESET_ALL )
3736
+
3724
3737
self .__class__ .testfiles = transcripts_expanded
3725
3738
sys .argv = [sys .argv [0 ]] # the --test argument upsets unittest.main()
3726
3739
testcase = TestMyAppCase ()
3727
3740
stream = utils .StdSim (sys .stderr )
3728
3741
runner = unittest .TextTestRunner (stream = stream )
3742
+ start_time = time .time ()
3729
3743
test_results = runner .run (testcase )
3744
+ execution_time = time .time () - start_time
3730
3745
if test_results .wasSuccessful ():
3731
3746
self ._decolorized_write (sys .stderr , stream .read ())
3732
- self .poutput ('Tests passed' , color = Fore .LIGHTGREEN_EX )
3747
+ finish_msg = '{0} transcript{1} passed in {2:.3f} seconds' .format (num_transcripts , plural , execution_time )
3748
+ self .poutput (Style .BRIGHT + utils .center_text (finish_msg , pad = '=' ) + Style .RESET_ALL , color = Fore .GREEN )
3733
3749
else :
3734
3750
# Strip off the initial traceback which isn't particularly useful for end users
3735
3751
error_str = stream .read ()
0 commit comments