Terminal Colors

HILSTER Testing Framework support terminal colors.

Terminal colors are automatically enabled if the terminal supports it.

They can be disabled by setting the environment variable HTF_NO_COLORS to any value.

To print colored text use the methods supplied by htf.termcolors.

Example:

import htf.termcolors as tc

print(tc.yellow("WARNING: this text an error in yellow"))
print(tc.red("ERROR: this text an error in red"))
print(tc.white_on_cyan_bold("HILSTER"))
import htf.termcolors as tc

tc.demo()
htf.termcolors.blue_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘blue’. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: None. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.critical(text: str) str

Return colored text if supported by terminal using ANSI codes for a critical error.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.debug(text: str) str

Return colored text if supported by terminal using ANSI codes for a critical error.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.error(text: str) str

Return colored text if supported by terminal using ANSI codes for an error.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.failure(text: str) str

Return colored text if supported by terminal using ANSI codes for a failure.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.green_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘green’. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.grey_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘grey’. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.info(text: str) str

Return colored text if supported by terminal using ANSI codes for an information.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.red_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘red’. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.skipped(text: str) str

Return colored text if supported by terminal using ANSI codes for something skipped.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.success(text: str) str

Return colored text if supported by terminal using ANSI codes for a success.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.system(text: str) str

Return colored text if supported by terminal using ANSI codes for system message.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.warning(text: str) str

Return colored text if supported by terminal using ANSI codes for a failure.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.yellow_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘yellow’. Background color: None. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str

htf.termcolors.yellow_on_red_bold(text)

Return colored text if supported by terminal using ANSI codes.

Foreground color: ‘yellow’. Background color: ‘on_red’. Attributes: bold.

Parameters:

text – the text to be colored.

Returns:

text colored if supported by the terminal.

Return type:

str