From 3e4c6f30d4f61a5aa74b4fab7f3ec8c93df2b168 Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Fri, 30 May 2008 15:07:43 -0700 Subject: Making difflib.HtmlDiff optional for compatibility with python 2.3. --- test-markdown.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'test-markdown.py') diff --git a/test-markdown.py b/test-markdown.py index 06696fa..3aed325 100644 --- a/test-markdown.py +++ b/test-markdown.py @@ -209,7 +209,10 @@ def testDirectory(dir, measure_time=False, safe_mode=False) : tests.sort() d = difflib.Differ() - hd = difflib.HtmlDiff() + try : + hd = difflib.HtmlDiff() + except: + ht = None htmlDiffFilePath = os.path.join(TMP_DIR, os.path.split(dir)[-1]) + ".html" htmlDiffFile = codecs.open(htmlDiffFilePath, "w", encoding=encoding) @@ -271,14 +274,15 @@ def testDirectory(dir, measure_time=False, safe_mode=False) : for line in diff : print line - htmlDiff = hd.make_table(expected_lines, actual_lines, - context=True) + if hd!=None : + htmlDiff = hd.make_table(expected_lines, actual_lines, + context=True) - htmlDiff = "\n".join( [x for x in htmlDiff.splitlines() - if x.strip().startswith("")] ) + htmlDiff = "\n".join( [x for x in htmlDiff.splitlines() + if x.strip().startswith("")] ) - diffsBuffer += "

%s

" % (test, test) - diffsBuffer += DIFF_TABLE_TEMPLATE % htmlDiff + diffsBuffer += "

%s

" % (test, test) + diffsBuffer += DIFF_TABLE_TEMPLATE % htmlDiff expected_time, expected_mem = saved_benchmarks.get(test, ("na", "na")) -- cgit v1.2.3