Various testcases.

tbot_contrib.utils.ensure_sd_unit(lnx: LinuxShell, services: List[str]) None[source]

check if all systemd services in list services run on linux machine lnx. If not, try to start them.

  • lnx – linux shell

  • services – list of systemd services

New in version 0.8.3.

tbot_contrib.utils.find_ip_address(lnx: LinuxShell, route_target: Optional[str] = None, force: bool = False) str[source]

Find out an IP-address of a host.

In times where most hosts have many IP addresses, this is not as trivial as one would like. This testcase approaches the problem by trying to find the IP-address, the host would use on a certain route.

By default, this is the route to reach a theoretical host at This will yield a sensible result in most cases but of course will not always be the address you want. For more fine-grained control you can pass a route_target. This is the IP-address of this theoretical host to reach.

  • lnx (linux.LinuxShell) – The host to work on.

  • route_target (str) – An optional route target. Defaults to

  • force (bool) – By default, this testcase caches results for faster lookup when called multiple times. This parameter enforces a re-check which might be useful when the network configuration on lnx changed.

Return type



The IP-address which was found.

New in version 0.8.3.

Changed in version 0.9.2: Fixed find_ip_address() not working properly when the route target is a local address.

tbot_contrib.utils.hashcmp(a: Path, b: Path) bool[source]

Compare the hashsum of two files (potentially from different hosts).

hashcmp() automatically selects a hash-summing tool which is available on both hosts and uses it to compare the checksum of the two files. It returns True if they match and False otherwise. If one of the files does not exist, False is returned.

New in version 0.9.2.

tbot_contrib.utils.strip_ansi_escapes(s: str) str[source]

Strip all ANSI escape sequences from a string

This helper can be used when programs have colored output and piping with | cat doesn’t help (e.g. forced color as with --color=always).

New in version 0.9.2.