Skip to content

Commit b951a18

Browse files
committed
If we have a diff with a known-good master in a testurl.list file, save the
failed file for inspection. - Legacy-Id: 6447
1 parent bc0e4e5 commit b951a18

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

ietf/utils/test_utils.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,25 @@ def doTestUrls(self, test_filename):
135135
failures = failures + 1
136136
self.assertEqual(failures, 0, "%d URLs failed" % failures)
137137

138+
def saveBadResponse(self, url, response):
139+
msg = "The %s page changed\n" % url
140+
url = url.lstrip('/')
141+
path = settings.TEST_DIFF_FAILURE_DIR
142+
path = os.path.join(path, url)
143+
if not os.path.exist(os.path.dirname(path)):
144+
os.mkdir(os.path.dirname(path))
145+
with open(path) as file:
146+
file.write(response)
147+
msg += "The newly generated page has been saved at:\n %s" % path
148+
return msg
149+
138150
def doTestUrl(self, tuple):
139151
(codes, url, master) = tuple
140152
baseurl, args = split_url(url)
141153
failed = False
142154
#enable this to see query counts
143155
#settings.DEBUG = True
156+
msg = None
144157
try:
145158
if "heavy" in codes and self.skip_heavy_tests:
146159
if self.verbosity > 1:
@@ -173,12 +186,14 @@ def doTestUrl(self, tuple):
173186
if code in codes and code == "200":
174187
diff_result = self.doDiff(tuple, response)
175188
if diff_result == False:
189+
msg = self.saveBadResponse(url, response)
176190
failed = True
177191
except:
178192
failed = True
179-
print "Exception for URL '%s'" % url
193+
msg = "Exception for URL '%s'" % url
194+
print msg
180195
traceback.print_exc()
181-
self.assertEqual(failed, False)
196+
self.assertEqual(failed, False, msg)
182197

183198
# Override this in subclasses if needed
184199
def doCanonicalize(self, url, content):

0 commit comments

Comments
 (0)