summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-04-26 12:52:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-04-26 12:52:42 -0400
commit59208c20ee0d312bc0da16e8d143ed8b70ec5079 (patch)
tree550e1f5c7d201fa33cc746b2e467d50fb9867156
parentc0dd3e9a1ffddd4799725b895e7d2033628698e9 (diff)
downloadpython-coveragepy-git-59208c20ee0d312bc0da16e8d143ed8b70ec5079.tar.gz
Use pipe symbol to join static and dynamic contexts
-rw-r--r--coverage/collector.py2
-rw-r--r--doc/contexts.rst3
-rw-r--r--tests/test_context.py6
-rw-r--r--tests/test_plugins.py6
4 files changed, 9 insertions, 8 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 4e7058a0..024540eb 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -376,7 +376,7 @@ class Collector(object):
if self.static_context:
context = self.static_context
if new_context:
- context += ":" + new_context
+ context += "|" + new_context
else:
context = new_context
self.covdata.set_context(context)
diff --git a/doc/contexts.rst b/doc/contexts.rst
index 8222747c..121bd491 100644
--- a/doc/contexts.rst
+++ b/doc/contexts.rst
@@ -62,7 +62,8 @@ Each test function you run will be considered a separate dynamic context, and
coverage data will be segregated for each. A test function is any function
whose names starts with "test".
-Ideas are welcome for other dynamic contexts that would be useful.
+If you have both a static context and a dynamic context, they are joined with a
+pipe symbol to be recorded as a single string.
Context reporting
diff --git a/tests/test_context.py b/tests/test_context.py
index f34a1062..1b50d30d 100644
--- a/tests/test_context.py
+++ b/tests/test_context.py
@@ -167,10 +167,10 @@ class DynamicContextTest(CoverageTest):
full_names = {os.path.basename(f): f for f in data.measured_files()}
fname = full_names["two_tests.py"]
- self.assertCountEqual(data.measured_contexts(), ["stat", "stat:test_one", "stat:test_two"])
+ self.assertCountEqual(data.measured_contexts(), ["stat", "stat|test_one", "stat|test_two"])
self.assertCountEqual(data.lines(fname, "stat"), self.OUTER_LINES)
- self.assertCountEqual(data.lines(fname, "stat:test_one"), self.TEST_ONE_LINES)
- self.assertCountEqual(data.lines(fname, "stat:test_two"), self.TEST_TWO_LINES)
+ self.assertCountEqual(data.lines(fname, "stat|test_one"), self.TEST_ONE_LINES)
+ self.assertCountEqual(data.lines(fname, "stat|test_two"), self.TEST_TWO_LINES)
class DynamicContextWithPythonTracerTest(CoverageTest):
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index f5a17619..264e7aea 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -1023,9 +1023,9 @@ class DynamicContextPluginTest(CoverageTest):
data = cov.get_data()
expected = [
'mytests',
- 'mytests:doctest:HTML_TAG',
- 'mytests:test:HTML_TAG',
- 'mytests:test:RENDERERS',
+ 'mytests|doctest:HTML_TAG',
+ 'mytests|test:HTML_TAG',
+ 'mytests|test:RENDERERS',
]
self.assertEqual(expected, sorted(data.measured_contexts()))