Sitelet https://github.com/python/cpython/commit/06d56f4a4a50c2d64622128a389f49341ebcbb03
Skip to content

Commit 06d56f4

Browse files
committed
Move cProfile test to run on both modules
1 parent 737d977 commit 06d56f4

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎Lib/test/test_cprofile.py‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ def test_bad_counter_during_dealloc(self):
3636
finally:
3737
unlink(TESTFN)
3838

39-
# Issue 21862
40-
def test_module_path_option(self):
41-
# Test -m switch with modules
42-
43-
# Test that -m switch needs an argument
44-
assert_python_failure('-m', 'cProfile', '-m')
45-
46-
# Test failure for not-existent module
47-
assert_python_failure('-m', 'cProfile', '-m', 'random_module_xyz')
48-
49-
# Test successful run
50-
assert_python_ok('-m', 'cProfile', '-m', 'timeit', '-n', '1')
51-
5239

5340
def test_main():
5441
run_unittest(CProfileTest)

‎Lib/test/test_profile.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import profile
1313
from test.profilee import testfunc, timer
14+
from test.support.script_helper import assert_python_failure, assert_python_ok
1415

1516

1617
class ProfileTest(unittest.TestCase):
@@ -93,6 +94,18 @@ def test_runctx(self):
9394
filename=TESTFN)
9495
self.assertTrue(os.path.exists(TESTFN))
9596

97+
def test_run_profile_as_module(self):
98+
# Test that -m switch needs an argument
99+
assert_python_failure('-m', self.profilermodule.__name__, '-m')
100+
101+
# Test failure for not-existent module
102+
assert_python_failure('-m', self.profilermodule.__name__,
103+
'-m', 'random_module_xyz')
104+
105+
# Test successful run
106+
assert_python_ok('-m', self.profilermodule.__name__,
107+
'-m', 'timeit', '-n', '1')
108+
96109

97110
def regenerate_expected_output(filename, cls):
98111
filename = filename.rstrip('co')

0 commit comments

Comments
 (0)