summaryrefslogtreecommitdiff
path: root/tests/test_html_formatter.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2007-02-14 17:32:51 +0100
committergbrandl <devnull@localhost>2007-02-14 17:32:51 +0100
commit1c8ddc632f1eb5550f98b8185b1b820069cb8efb (patch)
treef3372bb2aac222b9f70ba2fb03d3eb74a65ac7b4 /tests/test_html_formatter.py
parent3e1463ced2669526d6c1ea5cc7748438367c2847 (diff)
downloadpygments-1c8ddc632f1eb5550f98b8185b1b820069cb8efb.tar.gz
[svn] Add validation test for HTML formatter.
Diffstat (limited to 'tests/test_html_formatter.py')
-rw-r--r--tests/test_html_formatter.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_html_formatter.py b/tests/test_html_formatter.py
index a23fbfa9..ba3ed69e 100644
--- a/tests/test_html_formatter.py
+++ b/tests/test_html_formatter.py
@@ -11,6 +11,7 @@ import os
import unittest
import StringIO
import random
+import tempfile
from pygments import lexers, formatters
from pygments.token import _TokenType
@@ -34,4 +35,33 @@ class HtmlFormatterTest(unittest.TestCase):
outfile = StringIO.StringIO()
fmt = HtmlFormatter(**optdict)
fmt.format(tokensource, outfile)
-
+
+ def test_valid_output(self):
+ tokensource = list(PythonLexer().get_tokens(file(os.path.join(testdir, testfile)).read()))
+ fmt = HtmlFormatter(full=True, linenos=True, noclasses=True)
+
+ handle, pathname = tempfile.mkstemp('.html')
+ # place all output files in /tmp too
+ old_wd = os.getcwd()
+ os.chdir(os.path.dirname(pathname))
+ tfile = os.fdopen(handle, 'w+b')
+ fmt.format(tokensource, tfile)
+ tfile.close()
+ catname = os.path.join(testdir, 'dtds', 'HTML4.soc')
+ try:
+ try:
+ import subprocess
+ ret = subprocess.Popen(['nsgmls', '-s', '-c', catname, pathname],
+ stdout=subprocess.PIPE).wait()
+ except ImportError:
+ # Python 2.3 - no subprocess module
+ ret = os.popen('nsgmls -s -c "%s" "%s"' % (catname, pathname)).close()
+ if ret == 32512: raise OSError # not found
+ except OSError:
+ # latex not available
+ pass
+ else:
+ self.failIf(ret, 'nsgmls run reported errors')
+
+ os.unlink(pathname)
+ os.chdir(old_wd)