diff options
-rw-r--r-- | coverage/collector.py | 2 | ||||
-rw-r--r-- | doc/contexts.rst | 3 | ||||
-rw-r--r-- | tests/test_context.py | 6 | ||||
-rw-r--r-- | tests/test_plugins.py | 6 |
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())) |