diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2017-10-19 19:11:25 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-10-19 19:11:25 -0400 |
| commit | 0911c5b438fca2985eda9e578da5dc79bbd761af (patch) | |
| tree | fed24fa5bcd829d0ffafeb990144e47231f76ccb | |
| parent | f7fcd3633dc9f8c7805f74cac230cf50d2cfa022 (diff) | |
| download | python-coveragepy-0911c5b438fca2985eda9e578da5dc79bbd761af.tar.gz | |
Be more flexible about the command name in help. #600
| -rw-r--r-- | CHANGES.rst | 5 | ||||
| -rw-r--r-- | tests/test_cmdline.py | 15 |
2 files changed, 13 insertions, 7 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index bc44710..701ac0b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,11 @@ Unreleased longer counted in statement totals, which could slightly change your total results. +- Be more flexible about the command name displayed by help, fixing + `issue 600`_. Thanks, Ben Finney. + +.. _issue 600: https://bitbucket.org/ned/coveragepy/issues/600/get-program-name-from-command-line-when + .. _changes_441: diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index d7b5d30..a2c693a 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -643,27 +643,28 @@ class CmdLineStdoutTest(BaseCmdLineTest): self.assertLess(out.count("\n"), 4) def test_help_contains_command_name(self): - """ Command name should be present in help output. """ + # Command name should be present in help output. fake_command_path = "lorem/ipsum/dolor" expected_command_name = "dolor" fake_argv = [fake_command_path, "sit", "amet"] with mock.patch.object(sys, 'argv', new=fake_argv): self.command_line("help") + out = self.stdout() self.assertIn(expected_command_name, out) def test_help_contains_command_name_from_package(self): - """ - Command package name should be present in help output. + # Command package name should be present in help output. + # + # When the main module is actually a package's `__main__` module, the resulting command line + # has the `__main__.py` file's patch as the command name. Instead, the command name should + # be derived from the package name. - When the main module is actually a package's `__main__` module, the resulting command line - has the `__main__.py` file's patch as the command name. Instead, the command name should be - derived from the package name. - """ fake_command_path = "lorem/ipsum/dolor/__main__.py" expected_command_name = "dolor" fake_argv = [fake_command_path, "sit", "amet"] with mock.patch.object(sys, 'argv', new=fake_argv): self.command_line("help") + out = self.stdout() self.assertIn(expected_command_name, out) def test_help(self): |
