ok
Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/ |
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/plugin.cpython-311.pyc |
� �܋fEL � � � d Z ddlmZ ddlZddlmZ ddlmZmZm Z m Z mZmZm Z ddlmZ ddlmZ ddlmZmZmZmZ G d � d � � Z G d� d� � Z G d � de� � Zej G d� de� � � � ZdS )af .. versionadded:: 4.0 Plug-in interfaces for coverage.py. Coverage.py supports a few different kinds of plug-ins that change its behavior: * File tracers implement tracing of non-Python file types. * Configurers add custom configuration, using Python code to change the configuration. * Dynamic context switchers decide when the dynamic context has changed, for example, to record what test function produced the coverage. To write a coverage.py plug-in, create a module with a subclass of :class:`~coverage.CoveragePlugin`. You will override methods in your class to participate in various aspects of coverage.py's processing. Different types of plug-ins have to override different methods. Any plug-in can optionally implement :meth:`~coverage.CoveragePlugin.sys_info` to provide debugging information about their operation. Your module must also contain a ``coverage_init`` function that registers an instance of your plug-in class:: import coverage class MyPlugin(coverage.CoveragePlugin): ... def coverage_init(reg, options): reg.add_file_tracer(MyPlugin()) You use the `reg` parameter passed to your ``coverage_init`` function to register your plug-in object. The registration method you call depends on what kind of plug-in it is. If your plug-in takes options, the `options` parameter is a dictionary of your plug-in's options from the coverage.py configuration file. Use them however you want to configure your object before registering it. Coverage.py will store its own information on your plug-in object, using attributes whose names start with ``_coverage_``. Don't be startled. .. warning:: Plug-ins are imported by coverage.py before it begins measuring code. If you write a plugin in your own project, it might import your product code before coverage.py can start measuring. This can result in your own code being reported as missing. One solution is to put your plugins in your project tree, but not in your importable Python package. .. _file_tracer_plugins: File Tracers ============ File tracers implement measurement support for non-Python files. File tracers implement the :meth:`~coverage.CoveragePlugin.file_tracer` method to claim files and the :meth:`~coverage.CoveragePlugin.file_reporter` method to report on those files. In your ``coverage_init`` function, use the ``add_file_tracer`` method to register your file tracer. .. _configurer_plugins: Configurers =========== .. versionadded:: 4.5 Configurers modify the configuration of coverage.py during start-up. Configurers implement the :meth:`~coverage.CoveragePlugin.configure` method to change the configuration. In your ``coverage_init`` function, use the ``add_configurer`` method to register your configurer. .. _dynamic_context_plugins: Dynamic Context Switchers ========================= .. versionadded:: 5.0 Dynamic context switcher plugins implement the :meth:`~coverage.CoveragePlugin.dynamic_context` method to dynamically compute the context label for each measured frame. Computed context labels are useful when you want to group measured data without modifying the source code. For example, you could write a plugin that checks `frame.f_code` to inspect the currently executed method, and set the context label to a fully qualified method name if it's an instance method of `unittest.TestCase` and the method name starts with 'test'. Such a plugin would provide basic coverage grouping by test and could be used with test runners that have no built-in coveragepy support. In your ``coverage_init`` function, use the ``add_dynamic_context`` method to register your dynamic context switcher. � )�annotationsN)� FrameType)�Any�Dict�Iterable�Optional�Set�Tuple�Union)�files��_needs_to_implement)�TArc� TConfigurable�TLineNo�TSourceTokenLinesc �X � e Zd ZU dZded<