From c122b945403216fd89993b98138850d6b9a01488 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 29 Jul 2016 09:28:57 -0400 Subject: Separate auto-loading from auto-saving, and don't auto-load for subprocesses --- coverage/control.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index d3e67085..56a6afd6 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -164,7 +164,7 @@ class Coverage(object): ) self._debug_file = None - self._auto_data = auto_data + self._auto_load = self._auto_save = auto_data self._data_suffix = data_suffix # The matchers for _should_trace. @@ -697,7 +697,7 @@ class Coverage(object): # Calling start() means we're running code, so use the run_suffix # as the data_suffix when we eventually save the data. self.data_suffix = self.run_suffix - if self._auto_data: + if self._auto_load: self.load() self.collector.start() @@ -714,7 +714,7 @@ class Coverage(object): """Clean up on process shutdown.""" if self._started: self.stop() - if self._auto_data: + if self._auto_save: self.save() def erase(self): @@ -1209,11 +1209,12 @@ def process_startup(): # started coverage.py in this process. Nothing to do. return None - cov = Coverage(config_file=cps, auto_data=True) + cov = Coverage(config_file=cps) process_startup.coverage = cov cov.start() cov._warn_no_data = False cov._warn_unimported_source = False + cov._auto_save = True return cov @@ -1222,4 +1223,4 @@ def _prevent_sub_process_measurement(): """Stop any subprocess auto-measurement from writing data.""" auto_created_coverage = getattr(process_startup, "coverage", None) if auto_created_coverage is not None: - auto_created_coverage._auto_data = False + auto_created_coverage._auto_save = False -- cgit v1.2.1