from __future__ import print_function
+import cgi
import json
import pkg_resources
<script type="text/javascript" src="{}"></script>
<script type="text/javascript">{}</script>
</head><body></body></html>
- '''.format(self.label, self.JSLIB, self.js())
+ '''.format(cgi.escape(self.label), self.JSLIB, self.js())
def js(self):
return 'var sections = {};\n{}'.format(
self.diff_known_report(logfile, cmd)
+class HTMLFromFile(ReportDiff):
+ def test_example_files(self):
+ # Note we don't test the output content at all yet; we're
+ # mainly just verifying the --format=html option isn't ignored
+ # and the HTML code path doesn't crash.
+ for fnm in glob.glob(os.path.join(TESTS_DIR, '*.txt.gz')):
+ logfile = os.path.join(TESTS_DIR, fnm)
+ args = crunchstat_summary.command.ArgumentParser().parse_args(
+ ['--format=html', '--log-file', logfile])
+ cmd = crunchstat_summary.command.Command(args)
+ cmd.run()
+ self.assertRegexpMatches(cmd.report(), r'(?is)<html>.*</html>\s*$')
+
+
class SummarizeEdgeCases(unittest.TestCase):
def test_error_messages(self):
logfile = open(os.path.join(TESTS_DIR, 'crunchstat_error_messages.txt'))