* Adding 3 generic chunks, which will ignore the A-hat diffs and the
'produced by' diffs. * Updating ietf/tests.py to handle diff chunks right - Legacy-Id: 316
This commit is contained in:
parent
8e8c3ff5e2
commit
e7a13bff68
|
@ -97,7 +97,13 @@ class UrlTestCase(TestCase):
|
|||
for item in os.listdir(testdir):
|
||||
path = testdir + "/" + item
|
||||
if item.startswith("generic-") and os.path.isfile(path):
|
||||
self.diffchunks.append(filetext(path))
|
||||
chunk = filetext(path)
|
||||
chunk = re.sub(r"([\[\]().|+*?])", r"\\\1", chunk)
|
||||
# @@ -27,0 \+23,1 @@
|
||||
chunk = re.sub(r"(?m)^@@ -\d+,(\d+) \\\+\d+,(\d+) @@$", r"@@ -\d+,\1 \+\d+,\2 @@", chunk)
|
||||
#print "*** Installing diff chunk:"
|
||||
#print chunk
|
||||
self.diffchunks.append(chunk)
|
||||
|
||||
# extract application urls:
|
||||
self.patterns = get_patterns(ietf.urls)
|
||||
|
@ -165,8 +171,15 @@ class UrlTestCase(TestCase):
|
|||
contextlines = 0
|
||||
diff = "\n".join(unified_diff(goodtext, testtext, master, url, "", "", contextlines, lineterm=""))
|
||||
for chunk in self.diffchunks:
|
||||
if chunk in diff:
|
||||
diff = diff.replace(chunk, "")
|
||||
#print "*** Checking for chunk:", chunk[:24]
|
||||
while re.search(chunk, diff):
|
||||
#print "*** Removing chunk of %s lines" % (len(chunk.split("\n")))
|
||||
diff = re.sub(chunk, "", diff)
|
||||
if len(diff.strip().split()) == 2:
|
||||
# only the initial 2 lines of the diff remains --
|
||||
# discard them too
|
||||
diff = ""
|
||||
if diff:
|
||||
dfile = "%s/../test/diff/%s" % (settings.BASE_DIR, url.replace("/", "_"))
|
||||
if os.path.exists(dfile):
|
||||
dfile = open(dfile)
|
||||
|
|
3
test/diff/generic-diff_A-hat
Normal file
3
test/diff/generic-diff_A-hat
Normal file
|
@ -0,0 +1,3 @@
|
|||
@@ -16,1 +16,1 @@
|
||||
-request makes it into the ID tracker.) A document in this state has
|
||||
+request makes it into the ID tracker.) A document in this state has
|
6
test/diff/generic-diff_produced-by-1
Normal file
6
test/diff/generic-diff_produced-by-1
Normal file
|
@ -0,0 +1,6 @@
|
|||
@@ -12,0 +12,5 @@
|
||||
+Did you find a bug? Let us know .
|
||||
+
|
||||
+Any question or suggestion ?
|
||||
+
|
||||
+This page produced by the IETF Secretariat for the IESG
|
8
test/diff/generic-diff_produced-by-2
Normal file
8
test/diff/generic-diff_produced-by-2
Normal file
|
@ -0,0 +1,8 @@
|
|||
@@ -27,0 +23,1 @@
|
||||
+Did you find a bug? Let us know .
|
||||
@@ -28,0 +25,5 @@
|
||||
+Any question or suggestion ?
|
||||
+
|
||||
+This page produced by the IETF Secretariat for the IESG
|
||||
+
|
||||
+
|
Loading…
Reference in a new issue