diff -r a22ef88143b9 Lib/test/test_trace.py --- a/Lib/test/test_trace.py Sat Oct 25 23:05:21 2014 -0500 +++ b/Lib/test/test_trace.py Thu Oct 30 00:09:21 2014 +0700 @@ -1,6 +1,7 @@ import os import io import sys +from test.script_helper import assert_python_ok, assert_python_failure from test.support import (run_unittest, TESTFN, rmtree, unlink, captured_stdout) import unittest @@ -411,6 +412,22 @@ trace.find_executable_linenos(fd.name) +class TestCommandLine(unittest.TestCase): + + def test_listfuncs_flag_failure(self): + ok, stdout, stderr = assert_python_failure('-m', 'trace', '-l') + stderr = stderr.rstrip() + self.assertIn(b'missing name of file to run', stderr) + + def test_listfuncs_flag_success(self): + with open(TESTFN, 'w') as fd: + self.addCleanup(unlink, TESTFN) + fd.write("a = 1\n") + ok, stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN) + stdout = stdout.rstrip() + self.assertIn(b'functions called:', stdout) + + def test_main(): run_unittest(__name__) diff -r a22ef88143b9 Lib/trace.py --- a/Lib/trace.py Sat Oct 25 23:05:21 2014 -0500 +++ b/Lib/trace.py Thu Oct 30 00:09:21 2014 +0700 @@ -773,7 +773,7 @@ if report and not counts_file: _err_exit("--report requires a --file") - if no_report and len(prog_argv) == 0: + if (no_report or listfuncs) and len(prog_argv) == 0: _err_exit("missing name of file to run") # everything is ready