Skip to content

Commit 32ff871

Browse files
committed
fix: provide an intelligible error message for multiprocessing with no config file. #1320
1 parent dacea2d commit 32ff871

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Unreleased
2323
- Debug: added ``pybehave`` to the list of :ref:`cmd_debug` and
2424
:ref:`cmd_run_debug` options.
2525

26+
- Fix: show an intelligible error message if ``--concurrency=multiprocessing``
27+
is used without a configuration file. Closes `issue 1320`_.
28+
29+
.. _issue 1320: https://github.com/nedbat/coveragepy/issues/1320
30+
2631

2732
.. _changes_631:
2833

coverage/control.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ def _init_for_start(self):
462462
raise ConfigError( # pragma: only jython
463463
"multiprocessing is not supported on this Python"
464464
)
465+
if self.config.config_file is None:
466+
raise ConfigError("multiprocessing requires a configuration file")
465467
patch_multiprocessing(rcfile=self.config.config_file)
466468

467469
dycon = self.config.dynamic_context

tests/test_concurrency.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ def test_no_multiple_light_concurrency_in_config(self):
369369
with pytest.raises(ConfigError, match="Conflicting concurrency settings: eventlet, gevent"):
370370
self.command_line("run prog.py")
371371

372+
def test_multiprocessing_needs_config_file(self):
373+
with pytest.raises(ConfigError, match="multiprocessing requires a configuration file"):
374+
self.command_line("run --concurrency=multiprocessing prog.py")
375+
372376

373377
class WithoutConcurrencyModuleTest(CoverageTest):
374378
"""Tests of what happens if the requested concurrency isn't installed."""

0 commit comments

Comments
 (0)