.. _jgdv.debugging.trace_context: ============================ jgdv.debugging.trace_context ============================ .. py:module:: jgdv.debugging.trace_context Functions --------- .. autoapisummary:: jgdv.debugging.trace_context.must_have_results Classes ------- .. autoapisummary:: jgdv.debugging.trace_context.TraceContext jgdv.debugging.trace_context.TraceObj jgdv.debugging.trace_context.TraceWriter Module Contents =============== .. py:function:: must_have_results(fn) -> .. _jgdv.debugging.trace_context.TraceContext: .. py:class:: TraceContext(*, targets, track, logger = None, cache = None, timestamp = False, log_fmts = None) Utility to simplify using the trace library, as a context manager see https://docs.python.org/3/library/trace.html .. py:method:: _add_called(frame, curr) -> .. py:method:: _add_timestamp() -> .. py:method:: _add_trace(curr) -> .. py:method:: _log(key, *args) -> .. py:method:: _prepare_trace_for_writing(filter = None, *, line_nums = False) -> .. py:method:: _trace_call(frame) -> .. py:method:: _trace_line(frame) -> .. py:method:: _trace_return(frame) -> .. py:method:: assert_called(name) -> .. py:method:: assert_count(package, name, *, min = None, max = None) -> .. py:method:: blacklist(*args) -> Add string's to ignore to the context .. py:method:: ignores(curr) -> .. py:method:: sys_trace_h(frame, event, arg) -> The main handler method added to sys for tracing. .. py:method:: whitelist(*args) -> .. py:method:: write_coverage_dir(*, filter = None, root) -> Write the coverage trace into a flat directory of files .. py:method:: write_coverage_file(*, filter = None, target) -> Write the coverage trace into a single file .. py:method:: write_coverage_tree(*, filter = None, root, reroot = None) -> write the coverage trace into a tree of files .. py:attribute:: _blacklist :type: list[str] .. py:attribute:: _formatter :type: TraceWriter .. py:attribute:: _logger :type: jgdv.Maybe[logging.Logger] .. py:attribute:: _whitelist :type: list[str] .. py:attribute:: _write_to :type: jgdv.Maybe[pathlib.Path] .. py:attribute:: cache :type: jgdv.Maybe[pathlib.Path] .. py:attribute:: called :type: set[str] .. py:attribute:: callers :type: collections.defaultdict[str, set[str]] .. py:attribute:: counts :type: collections.defaultdict[tuple[str, str], int] .. py:attribute:: lines :type: list[TraceObj] .. py:attribute:: log_fmts :type: dict[str, str] .. py:attribute:: timestamp :type: bool .. py:attribute:: trace :type: list[TraceObj] .. py:attribute:: trace_targets :type: tuple[jgdv.debugging._interface.TraceEvent, Ellipsis] .. py:attribute:: track_targets :type: tuple[str, Ellipsis] .. _jgdv.debugging.trace_context.TraceObj: .. py:class:: TraceObj(frame) .. py:attribute:: count :type: int .. py:attribute:: file :type: jgdv.Maybe[str] .. py:attribute:: func :type: str .. py:property:: line :type: str .. py:attribute:: line_no :type: int .. py:attribute:: package :type: jgdv.Maybe[str] .. _jgdv.debugging.trace_context.TraceWriter: .. py:class:: TraceWriter .. py:method:: format_file_execution(*, file, trace, line_nums = False) -> .. py:method:: format_trace(trace) -> .. py:attribute:: exec_line :type: str .. py:attribute:: first_line :type: str .. py:attribute:: non_exec_line :type: str