diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-12 08:39:37 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-09-21 17:56:49 -0400 |
commit | 8c05c99a4782e67c75e361f3fcb06ae32559e5f1 (patch) | |
tree | 2c8daea4e424b3ec2615c2808932b9ff91ee9c37 /coverage | |
parent | d5d3427c92b78324beaba4babb281ac96eb1ebc1 (diff) | |
download | python-coveragepy-git-8c05c99a4782e67c75e361f3fcb06ae32559e5f1.tar.gz |
Set the context in the data
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/collector.py | 6 | ||||
-rw-r--r-- | coverage/control.py | 5 | ||||
-rw-r--r-- | coverage/sqldata.py | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/coverage/collector.py b/coverage/collector.py index db8373a1..e0144979 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -101,6 +101,8 @@ class Collector(object): self.threading = None self.covdata = None + self.static_context = None + self.origin = short_stack() self.concur_id_func = None @@ -161,9 +163,11 @@ class Collector(object): def __repr__(self): return "<Collector at 0x%x: %s>" % (id(self), self.tracer_name()) - def use_data(self, covdata): + def use_data(self, covdata, context): """Use `covdata` for recording data.""" self.covdata = covdata + self.static_context = context + self.covdata.set_context(self.static_context) def tracer_name(self): """Return the class name of the tracer we're using.""" diff --git a/coverage/control.py b/coverage/control.py index ca0843d7..0918a34e 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -366,6 +366,8 @@ class Coverage(object): self._init_data(suffix) + self._collector.use_data(self._data, self.config.context) + # Early warning if we aren't going to be able to support plugins. if self._plugins.file_tracers and not self._collector.supports_plugins: self._warn( @@ -401,9 +403,6 @@ class Coverage(object): debug=self._debug, ) - if self._collector is not None: - self._collector.use_data(self._data) - def start(self): """Start measuring code coverage. diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 641e8ae1..6dde9c2e 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -111,7 +111,7 @@ class CoverageSqliteData(SimpleRepr): self._db = Sqlite(self.filename, self._debug) with self._db: for stmt in SCHEMA.split(';'): - stmt = stmt.strip() + stmt = " ".join(stmt.strip().split()) if stmt: self._db.execute(stmt) self._db.execute("insert into coverage_schema (version) values (?)", (SCHEMA_VERSION,)) |