_pytest.terminal module

terminal reporting of the full testing process.

This is a good source for looking at the various reporting hooks.

_getdimensions() → Tuple[int, int][source]
get_terminal_width()int[source]
class MoreQuietAction(option_strings, dest, default=None, required=False, help=None)[source]

Bases: argparse.Action

a modified copy of the argparse count action which counts down and updates the legacy quiet attribute at the same time

used to unify verbosity handling

pytest_addoption(parser)[source]
pytest_configure(config: _pytest.config.Config)None[source]
getreportopt(config: _pytest.config.Config)str[source]
pytest_report_teststatus(report: _pytest.reports.TestReport) → Tuple[str, str, str][source]
class WarningReport(warning: warnings.WarningMessage, when: str, fslocation: Tuple[str, int], nodeid: Optional[str] = None)[source]

Bases: object

Holds information for warnings captured by TerminalReporter.pytest_warning_captured().

warning

The original warning.

when

When the warning was captured, e.g. “config”, “collect”, or “runtest” (see _pytest.hookspec.pytest_warning_captured()).

fslocation

Source of the warning (file system location, see get_location()).

nodeid

Node id that generated the warning (see get_location()).

count_towards_summary = True
message

Formatted warning (the standard way, without trailing newline).

source_line
get_location(config: _pytest.config.Config)str[source]

Returns the more user-friendly information about the location of a warning.

class TerminalReporter(config: _pytest.config.Config, file=None)[source]

Bases: object

_collect_ignored: Dict[str, List[py.path.local]]

Information about ignored paths (for reporting).

_determine_show_progress_info()[source]

Return True if we should display progress information based on the current config

verbosity
showheader
showfspath
showlongtestinfo
hasopt(char)[source]
write_fspath_result(nodeid, res, **markup)[source]
write_ensure_prefix(prefix, extra='', **kwargs)[source]
ensure_newline()[source]
write(content, **markup)[source]
write_line(line, **markup)[source]
rewrite(line, **markup)[source]

Rewinds the terminal cursor to the beginning and writes the given line.

Parameters

erase – if True, will also add spaces until the full terminal width to ensure previous lines are properly erased.

The rest of the keyword arguments are markup instructions.

write_sep(sep, title=None, **markup)[source]
section(title, sep='=', **kw)[source]
line(msg, **kw)[source]
_add_stats(category: str, items: List)None[source]
pytest_internalerror(excrepr)[source]
pytest_warning_captured(when: str, warning_message: warnings.WarningMessage, item: _pytest.nodes.Item)None[source]
pytest_plugin_registered(plugin)[source]
pytest_deselected(items)[source]
pytest_runtest_logstart(nodeid, location)[source]
pytest_runtest_logreport(report: _pytest.reports.TestReport)None[source]
_is_last_item
pytest_runtest_logfinish()None[source]

Write progress if past edge.

for ... in pytest_runtestloop() → Generator[None, None, None][source]

Write final progress indicator.

_get_progress_information_message()str[source]
_write_progress_information_filling_space()[source]
_width_of_current_line

Return the width of current line, using the superior implementation of py-1.6 when available

pytest_collection()None[source]
pytest_collectreport(report: _pytest.reports.CollectReport)None[source]
report_collect(final: bool = False)None[source]
_verbose_collect_ignored() → List[str][source]

Get information about ignored files during collection.

pytest_sessionstart(session: _pytest.main.Session)None[source]
_write_report_lines_from_hooks(lines)[source]
pytest_report_header(config: _pytest.config.Config) → List[str][source]
for ... in pytest_ignore_collect(path: py._path.local.LocalPath) → Generator[None, pluggy.callers._Result, None][source]

Register ignored files during collection for reporting.

pytest_collection_finish(session)[source]
_printcollecteditems(items: Sequence[_pytest.nodes.Item])None[source]
for ... in pytest_sessionfinish(session: _pytest.main.Session, exitstatus: _pytest.config.ExitCode)[source]
for ... in pytest_terminal_summary()[source]
pytest_keyboard_interrupt(excinfo: _pytest._code.code.ExceptionInfo)None[source]
pytest_unconfigure()[source]
_report_keyboardinterrupt()[source]
_locationline(nodeid, fspath, lineno, domain)[source]
_getfailureheadline(rep)[source]
_getcrashline(rep)[source]
getreports(name)[source]
summary_warnings()None[source]
summary_passes()[source]
_get_teardown_reports(nodeid: str) → List[_pytest.reports.TestReport][source]
_handle_teardown_sections(nodeid: str)None[source]
print_teardown_sections(rep: _pytest.reports.TestReport)None[source]
summary_failures()[source]
summary_errors()[source]
_outrep_summary(rep)[source]
summary_stats()None[source]
short_test_summary()None[source]
_get_main_color() → Tuple[str, List[str]][source]
_determine_main_color(unknown_type_seen: bool)str[source]
_set_main_color()None[source]
build_summary_stats_line() → Tuple[List[Tuple[str, Dict[str, bool]]], str][source]
_get_rep_reprcrash(rep: Union[_pytest.reports.CollectReport, _pytest.reports.TestReport], fulltrace: bool) → Optional[_pytest._code.code.ReprFileLocation][source]
_get_pos(config: _pytest.config.Config, rep: Union[_pytest.reports.CollectReport, _pytest.reports.TestReport])str[source]
_get_line_with_reprcrash_message(config: _pytest.config.Config, rep: Union[_pytest.reports.CollectReport, _pytest.reports.TestReport], termwidth: Optional[int])str[source]

Get summary line for a report, trying to add reprcrash message.

_folded_skips(skipped)[source]
_make_plural(count, noun)[source]
_plugin_nameversions(plugininfo) → List[str][source]
format_session_duration(seconds: float)str[source]

Format the given seconds in a human readable manner to show in the final summary