blob: 9489ed91f9c1cf6a19014324f3439186c237d202 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
"""Tests for the gprof2html script in the Tools directory."""
import os
import sys
import unittest
from unittest import mock
import tempfile
from test.test_tools import skip_if_missing, import_tool
skip_if_missing()
class Gprof2htmlTests(unittest.TestCase):
def setUp(self):
self.gprof = import_tool('gprof2html')
oldargv = sys.argv
def fixup():
sys.argv = oldargv
self.addCleanup(fixup)
sys.argv = []
def test_gprof(self):
# Issue #14508: this used to fail with a NameError.
with mock.patch.object(self.gprof, 'webbrowser') as wmock, \
tempfile.TemporaryDirectory() as tmpdir:
fn = os.path.join(tmpdir, 'abc')
open(fn, 'w').close()
sys.argv = ['gprof2html', fn]
self.gprof.main()
self.assertTrue(wmock.open.called)
if __name__ == '__main__':
unittest.main()
|