@@ -70,6 +70,18 @@ def read_testurls(filename):
7070 file .close ()
7171 return tuples
7272
73+ def filetext (filename ):
74+ file = open (filename )
75+ chunk = file .read ()
76+ file .close ()
77+ return chunk
78+
79+ def filetime (name ):
80+ if os .path .exists (name ):
81+ return os .stat (name )[stat .ST_MTIME ]
82+ else :
83+ return 0
84+
7385class UrlTestCase (TestCase ):
7486 def setUp (self ):
7587 from django .test .client import Client
@@ -78,13 +90,21 @@ def setUp(self):
7890 # find test urls
7991 self .testtuples = []
8092 self .testurls = []
93+ self .diffchunks = []
8194 for root , dirs , files in os .walk (settings .BASE_DIR ):
8295 if "testurl.list" in files :
8396 self .testtuples += read_testurls (root + "/testurl.list" )
8497 if "testurls.list" in files :
8598 self .testtuples += read_testurls (root + "/testurls.list" )
8699 self .testurls = [ tuple [1 ] for tuple in self .testtuples ]
87100
101+ # find diff chunks
102+ testdir = os .path .abspath (settings .BASE_DIR + "/../test/diff/" )
103+ for item in os .listdir (testdir ):
104+ path = testdir + "/" + item
105+ if item .startswith ("generic-" ) and os .path .isfile (path ):
106+ self .diffchunks .append (filetext (path ))
107+
88108 # extract application urls:
89109 self .patterns = get_patterns (ietf .urls )
90110 # Use the default database for the url tests, instead of the test database
@@ -148,7 +168,11 @@ def doUrlsTest(self, lst):
148168 if testtext == goodtext :
149169 print "OK cmp %s" % (url )
150170 else :
151- diff = "\n " .join (unified_diff (goodtext , testtext , url , master , lineterm = False ))
171+ contextlines = 0
172+ diff = "\n " .join (unified_diff (goodtext , testtext , master , url , "" , "" , contextlines , lineterm = "" ))
173+ for chunk in self .diffchunks :
174+ if chunk in diff :
175+ diff = diff .replace (chunk , "" )
152176 dfile = "%s/../test/diff/%s" % (settings .BASE_DIR , url .replace ("/" , "_" ))
153177 if os .path .exists (dfile ):
154178 dfile = open (dfile )
0 commit comments