1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import codecs 6 import os 7 import unittest 8 import tempfile 9 10 from tracing_build import vulcanize_trace_viewer 11 12 13 class Trace2HTMLTests(unittest.TestCase): 14 15 def testWriteHTMLForTracesToFile(self): 16 try: 17 # Note: We can't use "with" when working with tempfile.NamedTemporaryFile 18 # as that does not work on Windows. We use the longer, more clunky version 19 # instead. See https://bugs.python.org/issue14243 for detials. 20 raw_tmpfile = tempfile.NamedTemporaryFile( 21 mode='w', suffix='.html', delete=False) 22 raw_tmpfile.close() 23 with codecs.open(raw_tmpfile.name, 'w', encoding='utf-8') as tmpfile: 24 vulcanize_trace_viewer.WriteTraceViewer(tmpfile) 25 finally: 26 os.remove(raw_tmpfile.name) 27