Skip to content

Commit 74e9877

Browse files
committed
gh-131178: Add CLI tests for the profile module
1 parent 7e8a1b5 commit 74e9877

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Lib/test/test_profile.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,34 @@ def test_output_file_when_changing_directory(self):
134134

135135
self.assertTrue(os.path.exists('out.pstats'))
136136

137+
def test_sort(self):
138+
status, stdout, stderr = assert_python_ok(
139+
'-m', self.profilermodule.__name__,
140+
'-s', 'time', '-m', 'timeit', '-n', '1'
141+
)
142+
143+
output = stdout.decode()
144+
145+
self.assertIn("Ordered by:", output)
146+
147+
def test_help(self):
148+
status1, stdout1, stderr1 = assert_python_ok('-m', self.profilermodule.__name__, '-h')
149+
status2, stdout2, stderr2 = assert_python_ok('-m', self.profilermodule.__name__, '--help')
150+
151+
output1 = stdout1.decode()
152+
output2 = stdout2.decode()
153+
154+
self.assertIn("Usage:", output1)
155+
self.assertIn("Options:", output1)
156+
self.assertEqual(output1, output2)
157+
158+
def test_invalid_option(self):
159+
status, stdout, stderr = assert_python_failure('-m', self.profilermodule.__name__, '-invalidop')
160+
161+
output = stderr.decode()
162+
163+
self.assertIn("error: no such option", output)
164+
137165

138166
def regenerate_expected_output(filename, cls):
139167
filename = filename.rstrip('co')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add CLI tests for the profile module.

0 commit comments

Comments
 (0)