mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #21918: Convert test_tools.py to a sub-package of test.
This commit is contained in:
parent
52b2bc0369
commit
2b0a610297
10 changed files with 283 additions and 195 deletions
36
Lib/test/test_tools/test_gprof2html.py
Normal file
36
Lib/test/test_tools/test_gprof2html.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"""Tests for the gprof2html script in the Tools directory."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
import unittest
|
||||
from unittest import mock
|
||||
import tempfile
|
||||
|
||||
from test.test_tools import scriptsdir, 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 an 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue