tbot has its own logging mechanism to provide pretty output during a testcase run and extensive information about it afterwards. The tbot.log module contains the relevant code. Basically, everything centers about EventIO objects, which represent single log-events. These can either be created using one of the many existing log-event function, or manually, if the existing ones are not covering your case.



Boolean that is set if stdout supports unicode.

You should use tbot.log.u() instead of querying this flag.


Boolean that is set if tbot’s output should be colored.

You can use tbot.log.c() as an easy way to colorize your strings.

tbot.log.u(with_unicode: str, without_unicode: str)str[source]

Select a string depending on whether the terminal supports unicode.

  • with_unicode (str) – The string to be used if unicode is available

  • without_unicode (str) – The string to be used if unicode is not available

Return type



The selected string

class tbot.log.c(s: str)tbot.log.c

Color a string. Reexport from termcolor2


tbot.log.message(tbot.log.c("Message").yellow.bold + ": Hello World!")

s (str) – The string that should be colored

The following ‘attributes’ exist to restyle the text:

Foreground Color

Background Color

Style Attribute





















Log Events

tbot.log.message(msg: Union[str, termcolor2._C], verbosity: tbot.log.Verbosity = <Verbosity.INFO: 1>)tbot.log.EventIO[source]

Log a message.

  • msg (str) – The message

  • verbosity (Verbosity) – Message verbosity

tbot.log.warning(msg: Union[str, termcolor2._C])tbot.log.EventIO[source]

Emit a warning message.


msg (str) – The message

New in version 0.6.3.

tbot.log.skip(what: Union[str, termcolor2._C])tbot.log.EventIO[source]

Emit a testcase skip message.


what (str) – What test is being skipped

Deprecated since version 0.8: Use tbot.skip() instead.

tbot.log_event.command(mach: str, cmd: str)tbot.log.EventIO[source]

Log a command’s execution.

  • mach (str) – Name of the machine the command is run on

  • cmd (str) – The command itself

Return type



A stream that the output of the command should be written to.

tbot.log_event.testcase_begin(name: str)None[source]

Log a testcase’s beginning.


name (str) – Name of the testcase

tbot.log_event.testcase_end(name: str, duration: float, success: bool = True, skipped: Optional[str] = None)None[source]

Log a testcase’s end.

  • duration (float) – Time passed while this testcase ran

  • success (bool) – Whether the testcase succeeded

  • skipped (str) – None if the testcase ran normally or a string (the reason) if it was skipped. If a testcase was skipped, success is ignored.


class tbot.log.EventIO(ty: List[str], message: Union[str, termcolor2._C], *, verbosity: tbot.log.Verbosity = <Verbosity.INFO: 1>, nest_first: Optional[str] = None, **kwargs: Any)[source]

Bases: _io.StringIO

Stream for a log event.

Create a log event.

A log event is a io.StringIO and everything written to the stream will be added to the log event.


message (str) – First line of the log event (the log message). If the message contains newlines, only the first line will be printed as the message and the rest will be added to the log-event.