diff options
-rw-r--r-- | coverage/cmdline.py | 32 | ||||
-rw-r--r-- | test/test_cmdline.py | 6 |
2 files changed, 22 insertions, 16 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 59ef183d..ec74288c 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -1,6 +1,6 @@ """Command-line support for Coverage.""" -import optparse, re, sys, traceback +import optparse, sys, traceback from coverage.backward import sorted # pylint: disable=W0622 from coverage.execfile import run_python_file, run_python_module @@ -365,10 +365,7 @@ class CoverageScript(object): elif parser: print(parser.format_help().strip()) else: - # Parse out the topic we want from HELP_TOPICS - topic_list = re.split("(?m)^=+ (\w+) =+$", HELP_TOPICS) - topics = dict(zip(topic_list[1::2], topic_list[2::2])) - help_msg = topics.get(topic, '').strip() + help_msg = HELP_TOPICS.get(topic, '').strip() if help_msg: print(help_msg % self.covpkg.__dict__) else: @@ -581,9 +578,9 @@ def unshell_list(s): return s.split(',') -HELP_TOPICS = r""" - -== classic ==================================================================== +HELP_TOPICS = { +# ------------------------- +'classic': """\ Coverage.py version %(__version__)s Measure, collect, and report on code coverage in Python programs. @@ -628,8 +625,9 @@ coverage -a [-d DIR] [-i] [-o DIR,...] [FILE1 FILE2 ...] Coverage data is saved in the file .coverage by default. Set the COVERAGE_FILE environment variable to save it somewhere else. - -== help ======================================================================= +""", +# ------------------------- +'help': """\ Coverage.py, version %(__version__)s Measure, collect, and report on code coverage in Python programs. @@ -648,14 +646,16 @@ Commands: Use "coverage help <command>" for detailed help on any command. Use "coverage help classic" for help on older command syntax. For more information, see %(__url__)s - -== minimum_help =============================================================== +""", +# ------------------------- +'minimum_help': """\ Code coverage for Python. Use 'coverage help' for help. - -== version ==================================================================== +""", +# ------------------------- +'version': """\ Coverage.py, version %(__version__)s. %(__url__)s - -""" +""", +} def main(argv=None): diff --git a/test/test_cmdline.py b/test/test_cmdline.py index d4cc763d..e8e2336e 100644 --- a/test/test_cmdline.py +++ b/test/test_cmdline.py @@ -604,6 +604,12 @@ class CmdLineStdoutTest(CmdLineTest): assert "Code coverage for Python." in out assert out.count("\n") < 4 + def test_version(self): + self.command_line("--version") + out = self.stdout() + assert "ersion " in out + assert out.count("\n") < 4 + def test_help(self): self.command_line("help") out = self.stdout() |