coverage 7.13.1__cp314-cp314t-musllinux_1_2_aarch64.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 (61) 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 +197 -0
  6. coverage/cmdline.py +1220 -0
  7. coverage/collector.py +487 -0
  8. coverage/config.py +732 -0
  9. coverage/context.py +74 -0
  10. coverage/control.py +1514 -0
  11. coverage/core.py +139 -0
  12. coverage/data.py +251 -0
  13. coverage/debug.py +669 -0
  14. coverage/disposition.py +59 -0
  15. coverage/env.py +135 -0
  16. coverage/exceptions.py +85 -0
  17. coverage/execfile.py +329 -0
  18. coverage/files.py +553 -0
  19. coverage/html.py +860 -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 +389 -0
  26. coverage/htmlfiles/style.scss +844 -0
  27. coverage/inorout.py +590 -0
  28. coverage/jsonreport.py +200 -0
  29. coverage/lcovreport.py +218 -0
  30. coverage/misc.py +381 -0
  31. coverage/multiproc.py +120 -0
  32. coverage/numbits.py +146 -0
  33. coverage/parser.py +1215 -0
  34. coverage/patch.py +118 -0
  35. coverage/phystokens.py +197 -0
  36. coverage/plugin.py +617 -0
  37. coverage/plugin_support.py +299 -0
  38. coverage/pth_file.py +16 -0
  39. coverage/py.typed +1 -0
  40. coverage/python.py +272 -0
  41. coverage/pytracer.py +370 -0
  42. coverage/regions.py +127 -0
  43. coverage/report.py +298 -0
  44. coverage/report_core.py +117 -0
  45. coverage/results.py +502 -0
  46. coverage/sqldata.py +1212 -0
  47. coverage/sqlitedb.py +226 -0
  48. coverage/sysmon.py +509 -0
  49. coverage/templite.py +319 -0
  50. coverage/tomlconfig.py +212 -0
  51. coverage/tracer.cpython-314t-aarch64-linux-musl.so +0 -0
  52. coverage/tracer.pyi +43 -0
  53. coverage/types.py +214 -0
  54. coverage/version.py +35 -0
  55. coverage/xmlreport.py +263 -0
  56. coverage-7.13.1.dist-info/METADATA +200 -0
  57. coverage-7.13.1.dist-info/RECORD +61 -0
  58. coverage-7.13.1.dist-info/WHEEL +5 -0
  59. coverage-7.13.1.dist-info/entry_points.txt +4 -0
  60. coverage-7.13.1.dist-info/licenses/LICENSE.txt +177 -0
  61. coverage-7.13.1.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,197 @@
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 collections
9
+ import dis
10
+ from collections.abc import Iterable, Mapping
11
+ from types import CodeType
12
+ from typing import Optional
13
+
14
+ from coverage.types import TArc, TLineNo, TOffset
15
+
16
+
17
+ def code_objects(code: CodeType) -> Iterable[CodeType]:
18
+ """Iterate over all the code objects in `code`."""
19
+ stack = [code]
20
+ while stack:
21
+ # We're going to return the code object on the stack, but first
22
+ # push its children for later returning.
23
+ code = stack.pop()
24
+ for c in code.co_consts:
25
+ if isinstance(c, CodeType):
26
+ stack.append(c)
27
+ yield code
28
+
29
+
30
+ def op_set(*op_names: str) -> set[int]:
31
+ """Make a set of opcodes from instruction names.
32
+
33
+ The names might not exist in this version of Python, skip those if not.
34
+ """
35
+ ops = {op for name in op_names if (op := dis.opmap.get(name))}
36
+ assert ops, f"At least one opcode must exist: {op_names}"
37
+ return ops
38
+
39
+
40
+ # Opcodes that are unconditional jumps elsewhere.
41
+ ALWAYS_JUMPS = op_set(
42
+ "JUMP_BACKWARD",
43
+ "JUMP_BACKWARD_NO_INTERRUPT",
44
+ "JUMP_FORWARD",
45
+ )
46
+
47
+ # Opcodes that exit from a function.
48
+ RETURNS = op_set(
49
+ "RETURN_VALUE",
50
+ "RETURN_GENERATOR",
51
+ )
52
+
53
+ # Opcodes that do nothing.
54
+ NOPS = op_set(
55
+ "NOP",
56
+ "NOT_TAKEN",
57
+ )
58
+
59
+
60
+ class InstructionWalker:
61
+ """Utility to step through trails of instructions.
62
+
63
+ We have two reasons to need sequences of instructions from a code object:
64
+ First, in strict sequence to visit all the instructions in the object.
65
+ This is `walk(follow_jumps=False)`. Second, we want to follow jumps to
66
+ understand how execution will flow: `walk(follow_jumps=True)`.
67
+ """
68
+
69
+ def __init__(self, code: CodeType) -> None:
70
+ self.code = code
71
+ self.insts: dict[TOffset, dis.Instruction] = {}
72
+
73
+ inst = None
74
+ for inst in dis.get_instructions(code):
75
+ self.insts[inst.offset] = inst
76
+
77
+ assert inst is not None
78
+ self.max_offset = inst.offset
79
+
80
+ def walk(
81
+ self, *, start_at: TOffset = 0, follow_jumps: bool = True
82
+ ) -> Iterable[dis.Instruction]:
83
+ """
84
+ Yield instructions starting from `start_at`. Follow unconditional
85
+ jumps if `follow_jumps` is true.
86
+ """
87
+ seen = set()
88
+ offset = start_at
89
+ while offset < self.max_offset + 1:
90
+ if offset in seen:
91
+ break
92
+ seen.add(offset)
93
+ if inst := self.insts.get(offset):
94
+ yield inst
95
+ if follow_jumps and inst.opcode in ALWAYS_JUMPS:
96
+ offset = inst.jump_target
97
+ continue
98
+ offset += 2
99
+
100
+
101
+ TBranchTrailsOneSource = dict[Optional[TArc], set[TOffset]]
102
+ TBranchTrails = dict[TOffset, TBranchTrailsOneSource]
103
+
104
+
105
+ def branch_trails(
106
+ code: CodeType,
107
+ multiline_map: Mapping[TLineNo, TLineNo],
108
+ ) -> TBranchTrails:
109
+ """
110
+ Calculate branch trails for `code`.
111
+
112
+ `multiline_map` maps line numbers to the first line number of a
113
+ multi-line statement.
114
+
115
+ Instructions can have a jump_target, where they might jump to next. Some
116
+ instructions with a jump_target are unconditional jumps (ALWAYS_JUMPS), so
117
+ they aren't interesting to us, since they aren't the start of a branch
118
+ possibility.
119
+
120
+ Instructions that might or might not jump somewhere else are branch
121
+ possibilities. For each of those, we track a trail of instructions. These
122
+ are lists of instruction offsets, the next instructions that can execute.
123
+ We follow the trail until we get to a new source line. That gives us the
124
+ arc from the original instruction's line to the new source line.
125
+
126
+ """
127
+ the_trails: TBranchTrails = collections.defaultdict(lambda: collections.defaultdict(set))
128
+ iwalker = InstructionWalker(code)
129
+ for inst in iwalker.walk(follow_jumps=False):
130
+ if not inst.jump_target:
131
+ # We only care about instructions with jump targets.
132
+ continue
133
+ if inst.opcode in ALWAYS_JUMPS:
134
+ # We don't care about unconditional jumps.
135
+ continue
136
+
137
+ from_line = inst.line_number
138
+ if from_line is None:
139
+ continue
140
+ from_line = multiline_map.get(from_line, from_line)
141
+
142
+ def add_one_branch_trail(
143
+ trails: TBranchTrailsOneSource,
144
+ start_at: TOffset,
145
+ ) -> None:
146
+ # pylint: disable=cell-var-from-loop
147
+ inst_offsets: set[TOffset] = set()
148
+ to_line = None
149
+ for inst2 in iwalker.walk(start_at=start_at, follow_jumps=True):
150
+ inst_offsets.add(inst2.offset)
151
+ l2 = inst2.line_number
152
+ if l2 is not None:
153
+ l2 = multiline_map.get(l2, l2)
154
+ if l2 and l2 != from_line:
155
+ to_line = l2
156
+ break
157
+ elif inst2.jump_target and (inst2.opcode not in ALWAYS_JUMPS):
158
+ break
159
+ elif inst2.opcode in RETURNS:
160
+ to_line = -code.co_firstlineno
161
+ break
162
+ if to_line is not None:
163
+ trails[(from_line, to_line)].update(inst_offsets)
164
+ else:
165
+ trails[None] = set()
166
+
167
+ # Calculate two trails: one from the next instruction, and one from the
168
+ # jump_target instruction.
169
+ trails: TBranchTrailsOneSource = collections.defaultdict(set)
170
+ add_one_branch_trail(trails, start_at=inst.offset + 2)
171
+ add_one_branch_trail(trails, start_at=inst.jump_target)
172
+ the_trails[inst.offset] = trails
173
+
174
+ # Sometimes we get BRANCH_RIGHT or BRANCH_LEFT events from instructions
175
+ # other than the original jump possibility instruction. Register each
176
+ # trail under all of their offsets so we can pick up in the middle of a
177
+ # trail if need be.
178
+ for arc, offsets in trails.items():
179
+ for offset in offsets:
180
+ the_trails[offset][arc].update(offsets)
181
+
182
+ return the_trails
183
+
184
+
185
+ def always_jumps(code: CodeType) -> dict[TOffset, TOffset]:
186
+ """Make a map of unconditional bytecodes jumping to others.
187
+
188
+ Only include bytecodes that do no work and go to another bytecode.
189
+ """
190
+ jumps = {}
191
+ iwalker = InstructionWalker(code)
192
+ for inst in iwalker.walk(follow_jumps=False):
193
+ if inst.opcode in ALWAYS_JUMPS:
194
+ jumps[inst.offset] = inst.jump_target
195
+ elif inst.opcode in NOPS:
196
+ jumps[inst.offset] = inst.offset + 2
197
+ return jumps