88from mockable_test_result import MockableTestResult
99
1010from libs .colorama import init , Fore , Style
11+ import glob
12+ import path_to_enlightenment
13+
1114init ()
1215
1316
@@ -17,6 +20,12 @@ def __init__(self, stream):
1720 self .stream = stream
1821 self .prevTestClassName = None
1922 self .pass_count = 0
23+ self .lesson_pass_count = 0
24+ self .tests = path_to_enlightenment .koans ()
25+ self .all_lessons = glob .glob ('koans/about*.py' )
26+ self .all_lessons .remove ('koans/about_extra_credit.py' )
27+ self .total_lessons = len (self .all_lessons )
28+ self .total_koans = self .tests .countTestCases ()
2029
2130 def startTest (self , test ):
2231 MockableTestResult .startTest (self , test )
@@ -27,6 +36,8 @@ def startTest(self, test):
2736 self .stream .writeln ()
2837 self .stream .writeln ("{0}{1}Thinking {2}" .format (
2938 Fore .RESET , Style .NORMAL , helper .cls_name (test )))
39+ if helper .cls_name (test ) != 'AboutAsserts' :
40+ self .lesson_pass_count += 1
3041
3142 def addSuccess (self , test ):
3243 if self .passesCount ():
@@ -78,6 +89,8 @@ def learn(self):
7889
7990 self .stream .writeln ("" )
8091 self .stream .writeln ("" )
92+ self .stream .writeln (self .report_progress ())
93+ self .stream .writeln ("" )
8194 self .stream .writeln (self .say_something_zenlike ())
8295
8396 if self .failures : return
@@ -103,8 +116,8 @@ def errorReport(self):
103116 self .stream .writeln ("" )
104117 self .stream .writeln ("{0}{1}Please meditate on the following code:" \
105118 .format (Fore .RESET , Style .NORMAL ))
106- self .stream .writeln ("{0}{1}{2}" .format (Fore .YELLOW , Style .BRIGHT , \
107- self .scrapeInterestingStackDump (err )))
119+ self .stream .writeln ("{0}{1}{2}{3}{4} " .format (Fore .YELLOW , Style .BRIGHT , \
120+ self .scrapeInterestingStackDump (err ), Fore . RESET , Style . NORMAL ))
108121
109122 def scrapeAssertionError (self , err ):
110123 if not err : return ""
@@ -147,6 +160,15 @@ def scrapeInterestingStackDump(self, err):
147160 scrape += line + '\n '
148161 return scrape .replace (sep , '\n ' ).strip ('\n ' )
149162
163+ def report_progress (self ):
164+ lesson_progress = self .total_lessons - self .lesson_pass_count
165+ koans_progress = self .total_koans - self .pass_count
166+ return ("You are now {0}/{1} lessons and {2}/{3} koans away from " \
167+ "reaching enlightenment" .format (lesson_progress ,
168+ self .total_lessons ,
169+ koans_progress ,
170+ self .total_koans ))
171+
150172 # Hat's tip to Tim Peters for the zen statements from The Zen
151173 # of Python (http://www.python.org/dev/peps/pep-0020/)
152174 #
0 commit comments