diff options
author | Yuri Takhteyev <yuri@freewisdom.org> | 2008-05-30 15:07:43 -0700 |
---|---|---|
committer | Yuri Takhteyev <yuri@freewisdom.org> | 2008-05-30 15:07:43 -0700 |
commit | 3e4c6f30d4f61a5aa74b4fab7f3ec8c93df2b168 (patch) | |
tree | 48209320e158cd053582727d29050b9dfc88f061 /test-markdown.py | |
parent | 22188b4233a79387b49318acc8375da995224c43 (diff) | |
download | markdown-3e4c6f30d4f61a5aa74b4fab7f3ec8c93df2b168.tar.gz markdown-3e4c6f30d4f61a5aa74b4fab7f3ec8c93df2b168.tar.bz2 markdown-3e4c6f30d4f61a5aa74b4fab7f3ec8c93df2b168.zip |
Making difflib.HtmlDiff optional for compatibility with python 2.3.
Diffstat (limited to 'test-markdown.py')
-rw-r--r-- | test-markdown.py | 18 |
1 files changed, 11 insertions, 7 deletions
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("<tr>")] ) + htmlDiff = "\n".join( [x for x in htmlDiff.splitlines() + if x.strip().startswith("<tr>")] ) - diffsBuffer += "<a name='diff-%s'/><h2>%s</h2>" % (test, test) - diffsBuffer += DIFF_TABLE_TEMPLATE % htmlDiff + diffsBuffer += "<a name='diff-%s'/><h2>%s</h2>" % (test, test) + diffsBuffer += DIFF_TABLE_TEMPLATE % htmlDiff expected_time, expected_mem = saved_benchmarks.get(test, ("na", "na")) |