diff options
-rw-r--r-- | coverage/control.py | 8 | ||||
-rw-r--r-- | doc/config.rst | 2 | ||||
-rw-r--r-- | doc/contexts.rst | 2 | ||||
-rw-r--r-- | doc/dbschema.rst | 6 | ||||
-rw-r--r-- | doc/excluding.rst | 4 | ||||
-rw-r--r-- | doc/faq.rst | 4 | ||||
-rw-r--r-- | doc/plugins.rst | 14 | ||||
-rw-r--r-- | doc/source.rst | 2 |
8 files changed, 32 insertions, 10 deletions
diff --git a/coverage/control.py b/coverage/control.py index a0571c97..9c4a2ac7 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -424,11 +424,15 @@ class Coverage: appropriate Python value. For example, use True for booleans, not the string ``"True"``. - As an example, calling:: + As an example, calling: + + .. code-block:: python cov.set_option("run:branch", True) - has the same effect as this configuration file:: + has the same effect as this configuration file: + + .. code-block:: ini [run] branch = True diff --git a/doc/config.rst b/doc/config.rst index 70f56c0e..1b6f128d 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -7,6 +7,8 @@ Configuration reference ======================= +.. highlight:: ini + Coverage.py options can be specified in a configuration file. This makes it easier to re-run coverage.py with consistent settings, and also allows for specification of options that are otherwise only available in the diff --git a/doc/contexts.rst b/doc/contexts.rst index 1ea45d46..fbf94040 100644 --- a/doc/contexts.rst +++ b/doc/contexts.rst @@ -60,6 +60,8 @@ There are three ways to enable dynamic contexts: .. _pytest-cov: https://pypi.org/project/pytest-cov/ +.. highlight:: ini + The ``[run] dynamic_context`` setting has only one option now. Set it to ``test_function`` to start a new dynamic context for every test function:: diff --git a/doc/dbschema.rst b/doc/dbschema.rst index 9b5ee883..c93a0646 100644 --- a/doc/dbschema.rst +++ b/doc/dbschema.rst @@ -49,11 +49,11 @@ This is the database schema: .. [[[cog import textwrap from coverage.sqldata import SCHEMA - print(".. code::") + print(".. code-block:: sql") print() print(textwrap.indent(SCHEMA, " ")) .. ]]] -.. code:: +.. code-block:: sql CREATE TABLE coverage_schema ( -- One row, to record the version of the schema in this db. @@ -115,7 +115,7 @@ This is the database schema: foreign key (file_id) references file (id) ); -.. [[[end]]] (checksum: 207fbab355481686e0dce0a9d99d173c) +.. [[[end]]] (checksum: cfce1df016afbb43a5ff94306db56657) .. _numbits: diff --git a/doc/excluding.rst b/doc/excluding.rst index b89d449c..aa6c6298 100644 --- a/doc/excluding.rst +++ b/doc/excluding.rst @@ -7,6 +7,8 @@ Excluding code from coverage.py =============================== +.. highlight:: python + You may have code in your project that you know won't be executed, and you want to tell coverage.py to ignore it. For example, you may have debugging-only code that won't be executed during your unit tests. You can tell coverage.py to @@ -71,6 +73,8 @@ If the matched line introduces a block, the entire block is excluded from reporting. Matching a ``def`` line or decorator line will exclude an entire function. +.. highlight:: ini + For example, you might decide that __repr__ functions are usually only used in debugging code, and are uninteresting to test themselves. You could exclude all of them by adding a regex to the exclusion list:: diff --git a/doc/faq.rst b/doc/faq.rst index e6094283..e2fc2f28 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -54,7 +54,9 @@ Q: Can I find out which tests ran which lines? .............................................. Yes! Coverage.py has a feature called :ref:`dynamic_contexts` which can collect -this information. Add this to your .coveragerc file:: +this information. Add this to your .coveragerc file: + +.. code-block:: ini [run] dynamic_context = test_function diff --git a/doc/plugins.rst b/doc/plugins.rst index fae4f73b..c76e4f9b 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -25,21 +25,27 @@ To use a coverage.py plug-in, you install it and configure it. For this example, let's say there's a Python package called ``something`` that provides a coverage.py plug-in called ``something.plugin``. -#. Install the plug-in's package as you would any other Python package:: +#. Install the plug-in's package as you would any other Python package: - pip install something + .. code-block:: sh + + $ pip install something #. Configure coverage.py to use the plug-in. You do this by editing (or creating) your .coveragerc file, as described in :ref:`config`. The ``plugins`` setting indicates your plug-in. It's a list of importable - module names of plug-ins:: + module names of plug-ins: + + .. code-block:: ini [run] plugins = something.plugin #. If the plug-in needs its own configuration, you can add those settings in - the .coveragerc file in a section named for the plug-in:: + the .coveragerc file in a section named for the plug-in: + + .. code-block:: ini [something.plugin] option1 = True diff --git a/doc/source.rst b/doc/source.rst index 34aa611f..cfd0e6fc 100644 --- a/doc/source.rst +++ b/doc/source.rst @@ -57,6 +57,8 @@ file name patterns, specifying files not to measure. If both ``include`` and match the include patterns, then any files that match the omit pattern are removed from the set. +.. highlight:: ini + The ``include`` and ``omit`` file name patterns follow typical shell syntax: ``*`` matches any number of characters and ``?`` matches a single character. Patterns that start with a wildcard character are used as-is, other patterns |