diff options
author | Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com> | 2017-11-08 10:50:56 (GMT) |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2017-11-08 10:50:56 (GMT) |
commit | 7973e279a21999f134aff92dd6d344ec4591fae9 (patch) | |
tree | f8007dd3dac2f7cbf905f45ccd148cf4b5a1fd9a /Lib/test/test_cprofile.py | |
parent | 4fc4defd1c9bd667635ba4080404e7aa3fcd49ea (diff) | |
download | cpython-7973e279a21999f134aff92dd6d344ec4591fae9.zip cpython-7973e279a21999f134aff92dd6d344ec4591fae9.tar.gz cpython-7973e279a21999f134aff92dd6d344ec4591fae9.tar.bz2 |
bpo-21862: Add -m option to cProfile for profiling modules (#4297)
* bpo-21862: Add -m option to cProfile for profiling modules
Diffstat (limited to 'Lib/test/test_cprofile.py')
-rw-r--r-- | Lib/test/test_cprofile.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py index 53f8917..1430d22 100644 --- a/Lib/test/test_cprofile.py +++ b/Lib/test/test_cprofile.py @@ -6,6 +6,7 @@ from test.support import run_unittest, TESTFN, unlink # rip off all interesting stuff from test_profile import cProfile from test.test_profile import ProfileTest, regenerate_expected_output +from test.support.script_helper import assert_python_failure, assert_python_ok class CProfileTest(ProfileTest): @@ -35,6 +36,19 @@ class CProfileTest(ProfileTest): finally: unlink(TESTFN) + # Issue 21862 + def test_module_path_option(self): + # Test -m switch with modules + + # Test that -m switch needs an argument + assert_python_failure('-m', 'cProfile', '-m') + + # Test failure for not-existent module + assert_python_failure('-m', 'cProfile', '-m', 'random_module_xyz') + + # Test successful run + assert_python_ok('-m', 'cProfile', '-m', 'timeit', '-n', '1') + def test_main(): run_unittest(CProfileTest) |