`lineno` is the line number the arc starts from. `cause` is an English text fragment used as the `startmsg` for AstArcAnalyzer.missing_arc_fragments. It will be used to describe why an arc wasn't executed, so should fit well into a sentence of the form, "Line 17 didn't run because {cause}." The fragment can include "{lineno}" to have `lineno` interpolated into it. """ def __new__(cls, lineno, cause=None): return super(ArcStart, cls).__new__(cls, lineno, cause) # Define contract words that PyContract doesn't have. # ArcStarts is for a list or set of ArcStart's. new_contract('ArcStarts', lambda seq: all(isinstance(x, ArcStart) for x in seq)) # Turn on AST dumps with an environment variable. # $set_env.py: COVERAGE_AST_DUMP - Dump the AST nodes when parsing code. AST_DUMP = bool(int(os.environ.get("COVERAGE_AST_DUMP", 0))) class NodeList(object): """A synthetic fictitious node, containing a sequence of nodes. This is used when collapsing optimized if-statements, to represent the unconditional execution of one of the clauses. """ def __init__(self, body): self.body = body
A numbits is stored as a blob in the database. The exact meaning of the bytes in the blobs should be considered an implementation detail that might change in the future. Use these functions to work with those binary blobs of data. """ from coverage import env from coverage.backward import byte_to_int, bytes_to_ints, binary_bytes, zip_longest from coverage.misc import contract, new_contract if env.PY3: def _to_blob(b): """Convert a bytestring into a type SQLite will accept for a blob.""" return b new_contract('blob', lambda v: isinstance(v, bytes)) else: def _to_blob(b): """Convert a bytestring into a type SQLite will accept for a blob.""" return buffer(b) # pylint: disable=undefined-variable new_contract('blob', lambda v: isinstance(v, buffer)) # pylint: disable=undefined-variable @contract(nums='Iterable', returns='blob') def nums_to_numbits(nums): """Convert `nums` into a numbits. Arguments: nums: a reusable iterable of integers, the line numbers to store.
`lineno` is the line number the arc starts from. `cause` is an English text fragment used as the `startmsg` for AstArcAnalyzer.missing_arc_fragments. It will be used to describe why an arc wasn't executed, so should fit well into a sentence of the form, "Line 17 didn't run because {cause}." The fragment can include "{lineno}" to have `lineno` interpolated into it. """ def __new__(cls, lineno, cause=None): return super(ArcStart, cls).__new__(cls, lineno, cause) # Define contract words that PyContract doesn't have. # ArcStarts is for a list or set of ArcStart's. new_contract('ArcStarts', lambda seq: all(isinstance(x, ArcStart) for x in seq)) # Turn on AST dumps with an environment variable. AST_DUMP = bool(int(os.environ.get("COVERAGE_AST_DUMP", 0))) class NodeList(object): """A synthetic fictitious node, containing a sequence of nodes. This is used when collapsing optimized if-statements, to represent the unconditional execution of one of the clauses. """ def __init__(self, body): self.body = body self.lineno = body[0].lineno
the future. Use these functions to work with those binary blobs of data. """ import json from itertools import zip_longest from coverage.misc import contract, new_contract def _to_blob(b): """Convert a bytestring into a type SQLite will accept for a blob.""" return b new_contract('blob', lambda v: isinstance(v, bytes)) @contract(nums='Iterable', returns='blob') def nums_to_numbits(nums): """Convert `nums` into a numbits. Arguments: nums: a reusable iterable of integers, the line numbers to store. Returns: A binary blob. """ try: nbytes = max(nums) // 8 + 1 except ValueError: