diff options
-rw-r--r-- | CHANGES.rst | 4 | ||||
-rw-r--r-- | coverage/cmdline.py | 50 | ||||
-rw-r--r-- | tests/test_cmdline.py | 10 |
3 files changed, 37 insertions, 27 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index b811114d..a95eff25 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -37,6 +37,10 @@ Unreleased - Debug: The `coverage debug data` command will now sniff out combinable data files, and report on all of them. +- Debug: The `coverage debug` command used to accept a number of topics at a + time, and show all of them, though this was never documented. This no longer + works, to allow for command-line options in the future. + .. _issue 1203: https://github.com/nedbat/coveragepy/issues/1203 diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 070683b8..13783d76 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -778,31 +778,33 @@ class CoverageScript: if not args: show_help("What information would you like: config, data, sys, premain?") return ERR + if args[1:]: + show_help("Only one topic at a time, please") + return ERR - for info in args: - if info == 'sys': - sys_info = self.coverage.sys_info() - print(info_header("sys")) - for line in info_formatter(sys_info): - print(f" {line}") - elif info == 'data': - print(info_header("data")) - data_file = self.coverage.config.data_file - self.do_debug_data_file(data_file) - for filename in combinable_files(data_file): - print("-----") - self.do_debug_data_file(filename) - elif info == 'config': - print(info_header("config")) - config_info = self.coverage.config.__dict__.items() - for line in info_formatter(config_info): - print(f" {line}") - elif info == "premain": - print(info_header("premain")) - print(short_stack()) - else: - show_help(f"Don't know what you mean by {info!r}") - return ERR + if args[0] == 'sys': + sys_info = self.coverage.sys_info() + print(info_header("sys")) + for line in info_formatter(sys_info): + print(f" {line}") + elif args[0] == 'data': + print(info_header("data")) + data_file = self.coverage.config.data_file + self.do_debug_data_file(data_file) + for filename in combinable_files(data_file): + print("-----") + self.do_debug_data_file(filename) + elif args[0] == 'config': + print(info_header("config")) + config_info = sorted(self.coverage.config.__dict__.items()) + for line in info_formatter(config_info): + print(f" {line}") + elif args[0] == "premain": + print(info_header("premain")) + print(short_stack()) + else: + show_help(f"Don't know what you mean by {args[0]!r}") + return ERR return OK diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 112e5d68..f879461a 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -259,9 +259,13 @@ class CmdLineTest(BaseCmdLineTest): cov.save() """) - def test_debug(self): - self.cmd_help("debug", "What information would you like: config, data, sys, premain?") - self.cmd_help("debug foo", "Don't know what you mean by 'foo'") + @pytest.mark.parametrize("cmd, output", [ + ("debug", "What information would you like: config, data, sys, premain?"), + ("debug foo", "Don't know what you mean by 'foo'"), + ("debug sys config", "Only one topic at a time, please"), + ]) + def test_debug(self, cmd, output): + self.cmd_help(cmd, output) def test_debug_sys(self): self.command_line("debug sys") |