attach_table

typhoon.test.reporting.tables.attach_table(df, allure_title='', caption='', attach_as_step=False)
Adds HTML table with a simple CSS configuration to allure report. This type of table can be used to show:
  • Numbers

  • Strings

  • HTML Paragraph code (See typhoon.test.reporting.tables.text_style function)
    • Bold and Italic shape letters

    • Colors (See text_style docstring to be into all color options available)

Parameters:
  • df (pandas.DataFrame) – Dataframe with the table content.

  • allure_title (string) – It is an empty string (“”) by default. The title presented in the allure report.

  • caption (string) – It is an empty string (“”) by default. Table title attach directly to HTML code.

  • attach_as_step (bool - default False) – If set to False, table is added at the end of the report, no matter when in test it is actually attached. This is default allure behaviour, all the attachments are added at the end of the report. To overwrite this behaviour and place attachment in the report chronologically in the moment when it is added, it must be added in the separate report step. This is achieved by setting this argument to True.

Returns:

result – HTML code of the table.

Return type:

string

Examples

>>> from typhoon.test.reporting.tables import attach_table
>>> import pandas as pd
>>> import numpy as np
>>> from pathlib import Path
>>> df = pd.DataFrame(np.random.random(size=(10, 10)))
>>> # attach table to report and return html code of it
>>> html_code = attach_table(df, allure_title="Allure Table Title", caption="Allure Caption")
>>> html_file = str(Path(__file__).parent / "attached_table.html")
>>> with open(html_file, 'w') as fhtml:
>>>     fhtml.write(html_code)