coverage 7.15.4__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. a1_coverage.pth +1 -0
  2. coverage/__init__.py +38 -0
  3. coverage/__main__.py +12 -0
  4. coverage/annotate.py +113 -0
  5. coverage/bytecode.py +208 -0
  6. coverage/cmdline.py +1208 -0
  7. coverage/collector.py +498 -0
  8. coverage/config.py +728 -0
  9. coverage/context.py +74 -0
  10. coverage/control.py +1515 -0
  11. coverage/core.py +141 -0
  12. coverage/data.py +268 -0
  13. coverage/debug.py +667 -0
  14. coverage/disposition.py +59 -0
  15. coverage/env.py +142 -0
  16. coverage/exceptions.py +67 -0
  17. coverage/execfile.py +338 -0
  18. coverage/files.py +585 -0
  19. coverage/html.py +863 -0
  20. coverage/htmlfiles/coverage_html.js +735 -0
  21. coverage/htmlfiles/favicon_32.png +0 -0
  22. coverage/htmlfiles/index.html +199 -0
  23. coverage/htmlfiles/keybd_closed.png +0 -0
  24. coverage/htmlfiles/pyfile.html +149 -0
  25. coverage/htmlfiles/style.css +391 -0
  26. coverage/htmlfiles/style.scss +848 -0
  27. coverage/inorout.py +651 -0
  28. coverage/jsonreport.py +200 -0
  29. coverage/lcovreport.py +237 -0
  30. coverage/misc.py +382 -0
  31. coverage/multiproc.py +120 -0
  32. coverage/numbits.py +164 -0
  33. coverage/parser.py +1233 -0
  34. coverage/patch.py +118 -0
  35. coverage/phystokens.py +209 -0
  36. coverage/plugin.py +616 -0
  37. coverage/plugin_support.py +295 -0
  38. coverage/pth_file.py +16 -0
  39. coverage/py.typed +1 -0
  40. coverage/python.py +271 -0
  41. coverage/pytracer.py +367 -0
  42. coverage/regions.py +127 -0
  43. coverage/report.py +307 -0
  44. coverage/report_core.py +123 -0
  45. coverage/results.py +502 -0
  46. coverage/sqldata.py +1194 -0
  47. coverage/sqlitedb.py +223 -0
  48. coverage/sysmon.py +503 -0
  49. coverage/templite.py +315 -0
  50. coverage/tomlconfig.py +210 -0
  51. coverage/tracer.cp315-win_amd64.pyd +0 -0
  52. coverage/tracer.pyi +43 -0
  53. coverage/types.py +197 -0
  54. coverage/version.py +35 -0
  55. coverage/xmlreport.py +263 -0
  56. coverage-7.15.4.dist-info/METADATA +202 -0
  57. coverage-7.15.4.dist-info/RECORD +62 -0
  58. coverage-7.15.4.dist-info/WHEEL +5 -0
  59. coverage-7.15.4.dist-info/entry_points.txt +4 -0
  60. coverage-7.15.4.dist-info/licenses/LICENSE.txt +177 -0
  61. coverage-7.15.4.dist-info/licenses/NOTICE.txt +14 -0
  62. coverage-7.15.4.dist-info/top_level.txt +1 -0
a1_coverage.pth ADDED
@@ -0,0 +1 @@
1
+ import sys; exec('import os\n\nif os.getenv("COVERAGE_PROCESS_START") or os.getenv("COVERAGE_PROCESS_CONFIG"):\n try:\n import coverage\n except:\n pass\n else:\n coverage.process_startup(slug="pth")')
coverage/__init__.py ADDED
@@ -0,0 +1,38 @@
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
3
+
4
+ """
5
+ Code coverage measurement for Python.
6
+
7
+ Ned Batchelder
8
+ https://coverage.readthedocs.io
9
+
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ # mypy's convention is that "import as" names are public from the module.
15
+ # We import names as themselves to indicate that. Pylint sees it as pointless,
16
+ # so disable its warning.
17
+ # pylint: disable=useless-import-alias
18
+
19
+ from coverage.version import (
20
+ __version__ as __version__,
21
+ version_info as version_info,
22
+ )
23
+
24
+ from coverage.control import (
25
+ Coverage as Coverage,
26
+ process_startup as process_startup,
27
+ )
28
+ from coverage.data import CoverageData as CoverageData
29
+ from coverage.exceptions import CoverageException as CoverageException
30
+ from coverage.plugin import (
31
+ CodeRegion as CodeRegion,
32
+ CoveragePlugin as CoveragePlugin,
33
+ FileReporter as FileReporter,
34
+ FileTracer as FileTracer,
35
+ )
36
+
37
+ # Backward compatibility.
38
+ coverage = Coverage
coverage/__main__.py ADDED
@@ -0,0 +1,12 @@
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
3
+
4
+ """Coverage.py's main entry point."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import sys
9
+
10
+ from coverage.cmdline import main
11
+
12
+ sys.exit(main())
coverage/annotate.py ADDED
@@ -0,0 +1,113 @@
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
3
+
4
+ """Source file annotation for coverage.py."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import os
9
+ import re
10
+ from typing import TYPE_CHECKING
11
+
12
+ from coverage.files import flat_rootname
13
+ from coverage.misc import ensure_dir, isolate_module
14
+ from coverage.plugin import FileReporter
15
+ from coverage.report_core import get_analysis_to_report
16
+ from coverage.results import Analysis
17
+ from coverage.types import TMorfs
18
+
19
+ if TYPE_CHECKING:
20
+ from coverage import Coverage
21
+
22
+ os = isolate_module(os)
23
+
24
+
25
+ class AnnotateReporter:
26
+ """Generate annotated source files showing line coverage.
27
+
28
+ This reporter creates annotated copies of the measured source files. Each
29
+ .py file is copied as a .py,cover file, with a left-hand margin annotating
30
+ each line::
31
+
32
+ > def h(x):
33
+ - if 0: #pragma: no cover
34
+ - pass
35
+ > if x == 1:
36
+ ! a = 1
37
+ > else:
38
+ > a = 2
39
+
40
+ > h(2)
41
+
42
+ Executed lines use ">", lines not executed use "!", lines excluded from
43
+ consideration use "-".
44
+
45
+ """
46
+
47
+ def __init__(self, coverage: Coverage) -> None:
48
+ self.coverage = coverage
49
+ self.config = self.coverage.config
50
+ self.directory: str | None = None
51
+
52
+ blank_re = re.compile(r"\s*(#|$)")
53
+ else_re = re.compile(r"\s*else\s*:\s*(#|$)")
54
+
55
+ def report(self, morfs: TMorfs, directory: str | None = None) -> None:
56
+ """Run the report.
57
+
58
+ See `coverage.report()` for arguments.
59
+
60
+ """
61
+ self.directory = directory
62
+ self.coverage.get_data()
63
+ for fr, analysis in get_analysis_to_report(self.coverage, morfs):
64
+ self.annotate_file(fr, analysis)
65
+
66
+ def annotate_file(self, fr: FileReporter, analysis: Analysis) -> None:
67
+ """Annotate a single file.
68
+
69
+ `fr` is the FileReporter for the file to annotate.
70
+
71
+ """
72
+ statements = sorted(analysis.statements)
73
+ missing = sorted(analysis.missing)
74
+ excluded = sorted(analysis.excluded)
75
+
76
+ if self.directory:
77
+ ensure_dir(self.directory)
78
+ dest_file = os.path.join(self.directory, flat_rootname(fr.relative_filename()))
79
+ assert dest_file.endswith("_py")
80
+ dest_file = dest_file[:-3] + ".py"
81
+ else:
82
+ dest_file = fr.filename
83
+ dest_file += ",cover"
84
+
85
+ with open(dest_file, "w", encoding="utf-8") as dest:
86
+ i = j = 0
87
+ covered = True
88
+ source = fr.source()
89
+ for lineno, line in enumerate(source.splitlines(True), start=1):
90
+ while i < len(statements) and statements[i] < lineno:
91
+ i += 1
92
+ while j < len(missing) and missing[j] < lineno:
93
+ j += 1
94
+ if i < len(statements) and statements[i] == lineno:
95
+ covered = j >= len(missing) or missing[j] > lineno
96
+ if self.blank_re.match(line):
97
+ dest.write(" ")
98
+ elif self.else_re.match(line):
99
+ # Special logic for lines containing only "else:".
100
+ if j >= len(missing):
101
+ dest.write("> ")
102
+ elif statements[i] == missing[j]:
103
+ dest.write("! ")
104
+ else:
105
+ dest.write("> ")
106
+ elif lineno in excluded:
107
+ dest.write("- ")
108
+ elif covered:
109
+ dest.write("> ")
110
+ else:
111
+ dest.write("! ")
112
+
113
+ dest.write(line)
coverage/bytecode.py ADDED
@@ -0,0 +1,208 @@
1
+ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2
+ # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt
3
+
4
+ """Bytecode analysis for coverage.py"""
5
+
6
+ from __future__ import annotations
7
+
8
+ import dis
9
+ from collections.abc import Iterable, Mapping
10
+ from types import CodeType
11
+
12
+ from coverage.types import TArc, TLineNo, TOffset
13
+
14
+
15
+ class ByteParser:
16
+ """Parse bytecode to understand the structure of code."""
17
+
18
+ def __init__(
19
+ self,
20
+ *,
21
+ code: CodeType | None = None,
22
+ text: str | None = None,
23
+ filename: str | None = None,
24
+ ) -> None:
25
+ if code is None:
26
+ assert text is not None
27
+ code = compile(text, filename or "<string>", "exec", dont_inherit=True)
28
+ self.code = code
29
+
30
+ def _child_parsers(self) -> Iterable[ByteParser]:
31
+ """Iterate over all the code objects nested within this one.
32
+
33
+ The iteration includes `self` as its first value.
34
+
35
+ We skip code objects named `__annotate__` since they are deferred
36
+ annotations that usually are never run. If there are errors in the
37
+ annotations, they will be caught by type checkers or other tools that
38
+ use annotations.
39
+
40
+ """
41
+ return (ByteParser(code=c) for c in self.code_objects() if c.co_name != "__annotate__")
42
+
43
+ def code_objects(self) -> Iterable[CodeType]:
44
+ """Iterate over all the code objects in `code`."""
45
+ stack = [self.code]
46
+ while stack:
47
+ # We're going to return the code object on the stack, but first
48
+ # push its children for later returning.
49
+ code = stack.pop()
50
+ for c in code.co_consts:
51
+ if isinstance(c, CodeType):
52
+ stack.append(c)
53
+ yield code
54
+
55
+ def _line_numbers(self) -> Iterable[TLineNo]:
56
+ """Yield the line numbers possible in this code object.
57
+
58
+ Uses co_lines() to produce a sequence: l0, l1, ...
59
+ """
60
+ for _, _, line in self.code.co_lines():
61
+ if line:
62
+ yield line
63
+
64
+ def find_statements(self) -> Iterable[TLineNo]:
65
+ """Find the statements in `self.code`.
66
+
67
+ Produce a sequence of line numbers that start statements. Recurses
68
+ into all code objects reachable from `self.code`.
69
+
70
+ """
71
+ for bp in self._child_parsers():
72
+ # Get all of the lineno information from this code.
73
+ yield from bp._line_numbers()
74
+
75
+
76
+ def bytes_to_lines(code: CodeType) -> dict[TOffset, TLineNo]:
77
+ """Make a dict mapping byte code offsets to line numbers."""
78
+ b2l = {}
79
+ for bstart, bend, lineno in code.co_lines():
80
+ if lineno is not None:
81
+ for boffset in range(bstart, bend, 2):
82
+ b2l[boffset] = lineno
83
+ return b2l
84
+
85
+
86
+ def op_set(*op_names: str) -> set[int]:
87
+ """Make a set of opcodes from instruction names.
88
+
89
+ The names might not exist in this version of Python, skip those if not.
90
+ """
91
+ ops = {op for name in op_names if (op := dis.opmap.get(name))}
92
+ assert ops, f"At least one opcode must exist: {op_names}"
93
+ return ops
94
+
95
+
96
+ # Opcodes that are unconditional jumps elsewhere.
97
+ ALWAYS_JUMPS = op_set(
98
+ "JUMP_BACKWARD",
99
+ "JUMP_BACKWARD_NO_INTERRUPT",
100
+ "JUMP_FORWARD",
101
+ )
102
+
103
+ # Opcodes that exit from a function.
104
+ RETURNS = op_set(
105
+ "RETURN_VALUE",
106
+ "RETURN_GENERATOR",
107
+ )
108
+
109
+
110
+ # CACHE doesn't exist in Python 3.10, but the branch resolver is only used
111
+ # on 3.14+, so a placeholder value is fine.
112
+ _CACHE = dis.opmap.get("CACHE", -1)
113
+ _EXTENDED_ARG = dis.opmap["EXTENDED_ARG"]
114
+
115
+ # All opcodes with a jump target.
116
+ JUMPS = set(dis.hasjrel) | set(dis.hasjabs)
117
+
118
+ # Opcodes that jump backwards.
119
+ BACKWARD_JUMPS = {op for op in JUMPS if "JUMP_BACKWARD" in dis.opname[op]}
120
+
121
+
122
+ class BranchArcResolver:
123
+ """Resolve branch events to line arcs, one (source, dest) pair at a time.
124
+
125
+ Branch events are one-shot (they are DISABLEd after firing), so each
126
+ (source offset, destination offset) pair is resolved at most a couple of
127
+ times per code object. Resolving pairs on demand is much cheaper than
128
+ precomputing trails for every branch in the code object, most of which
129
+ never fire. We walk the raw bytecode bytes so that we never need to
130
+ disassemble whole code objects with `dis`.
131
+
132
+ To resolve one pair:
133
+ starting from the destination, follow the trail of instructions (through
134
+ unconditional jumps) until we reach an instruction on a new source line
135
+ (giving us the arc), a return (an arc to leaving the code object), or
136
+ another branch possibility (no arc: that branch will produce its own
137
+ events).
138
+
139
+ """
140
+
141
+ def __init__(
142
+ self,
143
+ code: CodeType,
144
+ byte_to_line: Mapping[TOffset, TLineNo],
145
+ multiline_map: Mapping[TLineNo, TLineNo],
146
+ ) -> None:
147
+ self.code = code
148
+ # co_code re-copies the bytes on each access, so fetch it once.
149
+ self.co_code = code.co_code
150
+ self.byte_to_line = byte_to_line
151
+ self.multiline_map = multiline_map
152
+
153
+ def line_at(self, offset: TOffset) -> TLineNo | None:
154
+ """The source line of the instruction at `offset`, de-multilined."""
155
+ line = self.byte_to_line.get(offset)
156
+ if line is not None:
157
+ line = self.multiline_map.get(line, line)
158
+ return line
159
+
160
+ def resolve(self, source: TOffset, dest: TOffset) -> TArc | None:
161
+ """Turn a branch event's (source, dest) offsets into an arc, or None."""
162
+ from_line = self.line_at(source)
163
+ if from_line is None:
164
+ return None
165
+ co_code = self.co_code
166
+ max_offset = len(co_code)
167
+ byte_to_line = self.byte_to_line
168
+ multiline_map = self.multiline_map
169
+ offset = dest
170
+ ext_arg = 0
171
+ seen: set[TOffset] = set()
172
+ while 0 <= offset < max_offset and offset not in seen:
173
+ seen.add(offset)
174
+ op = co_code[offset]
175
+ if op == _CACHE:
176
+ offset += 2
177
+ continue
178
+ if op == _EXTENDED_ARG:
179
+ ext_arg = (ext_arg | co_code[offset + 1]) << 8
180
+ offset += 2
181
+ continue
182
+ line = byte_to_line.get(offset)
183
+ if line is not None:
184
+ line = multiline_map.get(line, line)
185
+ if line and line != from_line:
186
+ return (from_line, line)
187
+ if op in JUMPS:
188
+ if op in ALWAYS_JUMPS:
189
+ arg = ext_arg | co_code[offset + 1]
190
+ # Jump distances are measured from the end of the
191
+ # instruction's inline CACHE entries, which appear in
192
+ # co_code as CACHE opcodes immediately following it.
193
+ next_offset = offset + 2
194
+ while next_offset < max_offset and co_code[next_offset] == _CACHE:
195
+ next_offset += 2
196
+ if op in BACKWARD_JUMPS:
197
+ offset = next_offset - 2 * arg
198
+ else:
199
+ offset = next_offset + 2 * arg
200
+ ext_arg = 0
201
+ continue
202
+ # Another branch possibility: it will get its own events.
203
+ return None
204
+ if op in RETURNS:
205
+ return (from_line, -self.code.co_firstlineno)
206
+ ext_arg = 0
207
+ offset += 2
208
+ return None