@@ -21,14 +21,17 @@ def run_tests(module_list, verbosity=1, extra_tests=[]):
2121 # during the search for a 'tests' module ...
2222 return django .test .simple .run_tests (module_list , verbosity , extra_tests )
2323
24- def reduce (html ):
24+ def reduce (html , pre = False , fill = True ):
2525 html = re .sub (" :" , ":" , html )
2626 if html .count ("<li>" ) > 5 * html .count ("</li>" ):
2727 html = html .replace ("<li>" , "</li><li>" )
28- text = html2text (html )
28+ text = html2text (html , pre = pre , fill = fill )
2929 text = text .replace ('."' , '".' )
3030 text = text .replace (',"' , '",' )
31- text = [ line .strip () for line in text .split ("\n " ) ]
31+ if pre :
32+ text = text .split ("\n " )
33+ else :
34+ text = [ line .strip () for line in text .split ("\n " ) ]
3235 return text
3336
3437def get_patterns (module ):
@@ -139,7 +142,11 @@ def testCoverage(self):
139142 #self.assertEqual(set(patterns), set(covered), "Not all the
140143 #application URLs has test cases. The missing are: %s" % (list(set(patterns) - set(covered))))
141144 if not set (self .patterns ) == set (covered ):
142- print "Not all the application URLs has test cases. The missing are: \n %s" % ("\n " .join (list (set (self .patterns ) - set (covered ))))
145+ missing = list (set (self .patterns ) - set (covered ))
146+ print "Not all the application URLs has test cases, there are %d missing." % (len (missing ))
147+ print "The ones missing are: "
148+ for pattern in missing :
149+ print "Miss" , pattern
143150 else :
144151 print "All the application URL patterns seem to have test cases."
145152 #print "Not all the application URLs has test cases."
@@ -175,18 +182,19 @@ def doUrlsTest(self, lst):
175182 try :
176183 mfile .close ()
177184 if goodhtml and response .content :
178- testtext = reduce (response .content )
179- goodtext = reduce (goodhtml )
180185 if "sort" in codes :
181- try :
182- def sorted (l ):
183- l .sort ()
184- return l
185- testtext = sorted (testtext )
186- goodtext = sorted (goodtext )
187- except :
188- print "Exception occurred when trying to do sorted comparison"
189- traceback .print_exc ()
186+ def sorted (l ):
187+ l .sort ()
188+ return l
189+ testtext = sorted (reduce (response .content , fill = False ))
190+ while testtext and not testtext [0 ]:
191+ del testtext [0 ]
192+ goodtext = sorted (reduce (goodhtml , fill = False ))
193+ while goodtext and not goodtext [0 ]:
194+ del goodtext [0 ]
195+ else :
196+ testtext = reduce (response .content )
197+ goodtext = reduce (goodhtml )
190198 if testtext == goodtext :
191199 print "OK cmp %s" % (url )
192200 else :
0 commit comments