summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/cmdline.py4
-rw-r--r--tests/test_cmdline.py20
2 files changed, 21 insertions, 3 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index b45547ba..d04da399 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -603,6 +603,10 @@ class CoverageScript(object):
"""Implementation of 'coverage run'."""
if not args:
+ if options.module:
+ # Specified -m with nothing else.
+ self.help_fn("No module specified for -m")
+ return ERR
command_line = self.coverage.get_option("run:command_line")
if command_line is not None:
args = shlex.split(command_line)
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index e7d3fafa..ff035764 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -540,7 +540,6 @@ class CmdLineTest(BaseCmdLineTest):
)
def test_run_module_from_config(self):
- options = {"run:command_line": "-m mymodule thing1 thing2"}
self.cmd_executes("run", """\
.Coverage()
.start()
@@ -548,7 +547,7 @@ class CmdLineTest(BaseCmdLineTest):
.stop()
.save()
""",
- options=options,
+ options={"run:command_line": "-m mymodule thing1 thing2"},
)
def test_run_from_config_but_empty(self):
@@ -556,10 +555,25 @@ class CmdLineTest(BaseCmdLineTest):
.Coverage()
.help_fn('Nothing to do.')
""",
- ret=1,
+ ret=ERR,
options={"run:command_line": ""},
)
+ def test_run_dashm_only(self):
+ self.cmd_executes("run -m", """\
+ .Coverage()
+ .help_fn('No module specified for -m')
+ """,
+ ret=ERR,
+ )
+ self.cmd_executes("run -m", """\
+ .Coverage()
+ .help_fn('No module specified for -m')
+ """,
+ ret=ERR,
+ options={"run:command_line": "myprog.py"}
+ )
+
def test_cant_append_parallel(self):
self.command_line("run --append --parallel-mode foo.py", ret=ERR)
self.assertIn("Can't append to data files in parallel mode.", self.stderr())