Skip to content

Commit

Permalink
fix: provide an intelligible error message for multiprocessing with n…
Browse files Browse the repository at this point in the history
…o config file. #1320
  • Loading branch information
nedbat committed Feb 9, 2022
1 parent dacea2d commit 32ff871
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Unreleased
- Debug: added ``pybehave`` to the list of :ref:`cmd_debug` and
:ref:`cmd_run_debug` options.

- Fix: show an intelligible error message if ``--concurrency=multiprocessing``
is used without a configuration file. Closes `issue 1320`_.

.. _issue 1320: https://github.com/nedbat/coveragepy/issues/1320


.. _changes_631:

Expand Down
2 changes: 2 additions & 0 deletions coverage/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ def _init_for_start(self):
raise ConfigError( # pragma: only jython
"multiprocessing is not supported on this Python"
)
if self.config.config_file is None:
raise ConfigError("multiprocessing requires a configuration file")
patch_multiprocessing(rcfile=self.config.config_file)

dycon = self.config.dynamic_context
Expand Down
4 changes: 4 additions & 0 deletions tests/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ def test_no_multiple_light_concurrency_in_config(self):
with pytest.raises(ConfigError, match="Conflicting concurrency settings: eventlet, gevent"):
self.command_line("run prog.py")

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


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

0 comments on commit 32ff871

Please sign in to comment.