Skip to content

Commit 8c05c99

Browse files
committed
Set the context in the data
1 parent d5d3427 commit 8c05c99

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

coverage/collector.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def __init__(self, should_trace, check_include, timid, branch, warn, concurrency
101101
self.threading = None
102102
self.covdata = None
103103

104+
self.static_context = None
105+
104106
self.origin = short_stack()
105107

106108
self.concur_id_func = None
@@ -161,9 +163,11 @@ def __init__(self, should_trace, check_include, timid, branch, warn, concurrency
161163
def __repr__(self):
162164
return "<Collector at 0x%x: %s>" % (id(self), self.tracer_name())
163165

164-
def use_data(self, covdata):
166+
def use_data(self, covdata, context):
165167
"""Use `covdata` for recording data."""
166168
self.covdata = covdata
169+
self.static_context = context
170+
self.covdata.set_context(self.static_context)
167171

168172
def tracer_name(self):
169173
"""Return the class name of the tracer we're using."""

coverage/control.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ def _init_for_start(self):
366366

367367
self._init_data(suffix)
368368

369+
self._collector.use_data(self._data, self.config.context)
370+
369371
# Early warning if we aren't going to be able to support plugins.
370372
if self._plugins.file_tracers and not self._collector.supports_plugins:
371373
self._warn(
@@ -401,9 +403,6 @@ def _init_data(self, suffix):
401403
debug=self._debug,
402404
)
403405

404-
if self._collector is not None:
405-
self._collector.use_data(self._data)
406-
407406
def start(self):
408407
"""Start measuring code coverage.
409408

coverage/sqldata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _create_db(self):
111111
self._db = Sqlite(self.filename, self._debug)
112112
with self._db:
113113
for stmt in SCHEMA.split(';'):
114-
stmt = stmt.strip()
114+
stmt = " ".join(stmt.strip().split())
115115
if stmt:
116116
self._db.execute(stmt)
117117
self._db.execute("insert into coverage_schema (version) values (?)", (SCHEMA_VERSION,))

0 commit comments

Comments
 (0)