Skip to content

Table Reporter

ReportTable

ReportTable()

Create a rich.Table instance based on an anta.result_manager.ResultManager instance.

Attributes:

Name Type Description
title

Title used when creating the rich.Table instance. See ReportTable.Title for the default values.

columns

Column names used when creating the rich.Table instance. See ReportTable.Columns for the default values.

Columns dataclass

Columns(
    device: str = "Device",
    test: str = "Test",
    category: str = "Category",
    status: str = "Status",
    messages: str = "Message(s)",
    description: str = "Description",
    number_of_success: str = "# of success",
    number_of_failure: str = "# of failure",
    number_of_skipped: str = "# of skipped",
    number_of_errors: str = "# of errors",
    failed_devices: str = "List of devices with failed or errored tests",
    failed_tests: str = "List of failed or errored tests",
)

Column names for the table report.

Title dataclass

Title(
    all: str = "All tests results",
    tests: str = "Summary per test",
    device: str = "Summary per device",
)

Titles for the table report.

generate

generate(manager: ResultManager) -> Table

Create a table report with all tests.

Attributes used to build the table are:

Table title: `title.all`
Table columns:
    - `columns.category`
    - `columns.device`
    - `columns.test`
    - `columns.description`
    - `columns.status`
    - `columns.messages`

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required

Returns:

Type Description
A fully populated rich `Table`.
Source code in anta/reporter/__init__.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def generate(self, manager: ResultManager) -> Table:
    """Create a table report with all tests.

    Attributes used to build the table are:

        Table title: `title.all`
        Table columns:
            - `columns.category`
            - `columns.device`
            - `columns.test`
            - `columns.description`
            - `columns.status`
            - `columns.messages`

    Parameters
    ----------
    manager
        A ResultManager instance.

    Returns
    -------
        A fully populated rich `Table`.
    """
    columns = [self.columns.category, self.columns.device, self.columns.test, self.columns.description, self.columns.status, self.columns.messages]

    table = ReportTable._build_table(title=self.title.all, columns=columns)

    for result in manager.results:
        state = self._color_result(result.result)
        message = self._split_list_to_txt_list(result.messages) if len(result.messages) > 0 else ""
        categories = ", ".join(convert_categories(result.categories))
        renderables: list[str | None] = [categories, str(result.name), result.test, result.description, state, message]
        table.add_row(*renderables)
    return table

generate_expanded

generate_expanded(manager: ResultManager) -> Table

Create a table report with all tests, expanded atomic results, test descriptions.

Attributes used to build the table are:

Table title: `title.all`
Table columns:
    - `columns.category`
    - `columns.device`
    - `columns.test`
    - `columns.description`
    - `columns.status`
    - `columns.messages`

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required

Returns:

Type Description
Table

A fully populated rich Table.

Source code in anta/reporter/__init__.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
def generate_expanded(self, manager: ResultManager) -> Table:
    """Create a table report with all tests, expanded atomic results, test descriptions.

    Attributes used to build the table are:

        Table title: `title.all`
        Table columns:
            - `columns.category`
            - `columns.device`
            - `columns.test`
            - `columns.description`
            - `columns.status`
            - `columns.messages`

    Parameters
    ----------
    manager
        A ResultManager instance.

    Returns
    -------
    Table
        A fully populated rich `Table`.
    """
    columns = [
        self.columns.category,
        self.columns.device,
        self.columns.test,
        self.columns.description,
        self.columns.status,
        self.columns.messages,
    ]

    table = ReportTable._build_table(title=self.title.all, columns=columns)

    def add_line(result: TestResult | AtomicTestResult, suffix: str | None = None) -> None:
        categories = device = test = None

        if isinstance(result, TestResult):
            categories = ", ".join(convert_categories(result.categories))
            device = str(result.name)
            test = result.test
        else:  # AtomicTestResult
            if suffix is None:  # pragma: no cover
                # This should never happen
                msg = "Cannot generate a report line for AtomicTestResult without a suffix"
                raise ValueError(msg)
            test = f"{result.parent.test} {suffix}"

        state = self._color_result(result.result)
        message = self._split_list_to_txt_list(result.messages) if len(result.messages) > 0 else ""
        renderables = [categories, test, device, result.description, state, message]
        table.add_row(*renderables)

    for result in manager.results:
        add_line(result)
        for index, atomic_res in enumerate(result.atomic_results):
            add_line(atomic_res, f"{index + 1}/{len(result.atomic_results)}")
    return table

generate_summary_by_device

generate_summary_by_device(
    manager: ResultManager,
    *,
    devices: set[str] | None = None
) -> Table

Create a table report with results aggregated per device.

Attributes used to build the table are:

Table title: `title.device`
Table columns:
    - `columns.device`
    - `columns.number_of_success`
    - `columns.number_of_skipped`
    - `columns.number_of_failure`
    - `columns.number_of_errors`
    - `columns.failed_tests`

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required
devices set[str] | None

List of device names to include. None to select all devices.

None

Returns:

Type Description
A fully populated rich `Table`.
Source code in anta/reporter/__init__.py
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
def generate_summary_by_device(
    self,
    manager: ResultManager,
    *,
    devices: set[str] | None = None,
) -> Table:
    """Create a table report with results aggregated per device.

    Attributes used to build the table are:

        Table title: `title.device`
        Table columns:
            - `columns.device`
            - `columns.number_of_success`
            - `columns.number_of_skipped`
            - `columns.number_of_failure`
            - `columns.number_of_errors`
            - `columns.failed_tests`

    Parameters
    ----------
    manager
        A ResultManager instance.
    devices
        List of device names to include. None to select all devices.

    Returns
    -------
        A fully populated rich `Table`.
    """
    columns = [
        self.columns.device,
        self.columns.number_of_success,
        self.columns.number_of_skipped,
        self.columns.number_of_failure,
        self.columns.number_of_errors,
        self.columns.failed_tests,
    ]
    table = ReportTable._build_table(title=self.title.device, columns=columns)
    for device, stats in manager.device_stats.items():
        if devices is None or device in devices:
            table.add_row(
                device,
                str(stats.tests_success_count),
                str(stats.tests_skipped_count),
                str(stats.tests_failure_count),
                str(stats.tests_error_count),
                ", ".join(stats.tests_failure),
            )
    return table

generate_summary_by_test

generate_summary_by_test(
    manager: ResultManager, *, tests: set[str] | None = None
) -> Table

Create a table report with results aggregated per test.

Attributes used to build the table are:

Table title: `title.tests`
Table columns:
    - `columns.test`
    - `columns.number_of_success`
    - `columns.number_of_skipped`
    - `columns.number_of_failure`
    - `columns.number_of_errors`
    - `columns.failed_devices`

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required
tests set[str] | None

List of test names to include. None to select all tests.

None

Returns:

Type Description
A fully populated rich `Table`.
Source code in anta/reporter/__init__.py
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
def generate_summary_by_test(self, manager: ResultManager, *, tests: set[str] | None = None) -> Table:
    """Create a table report with results aggregated per test.

    Attributes used to build the table are:

        Table title: `title.tests`
        Table columns:
            - `columns.test`
            - `columns.number_of_success`
            - `columns.number_of_skipped`
            - `columns.number_of_failure`
            - `columns.number_of_errors`
            - `columns.failed_devices`

    Parameters
    ----------
    manager
        A ResultManager instance.
    tests
        List of test names to include. None to select all tests.

    Returns
    -------
        A fully populated rich `Table`.
    """
    columns = [
        self.columns.test,
        self.columns.number_of_success,
        self.columns.number_of_skipped,
        self.columns.number_of_failure,
        self.columns.number_of_errors,
        self.columns.failed_devices,
    ]
    table = ReportTable._build_table(title=self.title.tests, columns=columns)

    for test, stats in manager.test_stats.items():
        if tests is None or test in tests:
            table.add_row(
                test,
                str(stats.devices_success_count),
                str(stats.devices_skipped_count),
                str(stats.devices_failure_count),
                str(stats.devices_error_count),
                ", ".join(stats.devices_failure),
            )
    return table

report_all deprecated

report_all(
    manager: ResultManager, title: str = "All tests results"
) -> Table
Deprecated

This method is deprecated, use generate instead. This will be removed in ANTA v2.0.0.

Create a table report with all tests for one or all devices.

Create table with full output: Device | Test Name | Test Status | Message(s) | Test description | Test category

Warnings
  • This method sets the report.title.all value which impacts future calls to generate_* methods.

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required
title str

Title for the report. Defaults to ‘All tests results’.

'All tests results'

Returns:

Type Description
Table

A fully populated rich Table.

Source code in anta/reporter/__init__.py
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
@deprecated("This method is deprecated, use `generate` instead. This will be removed in ANTA v2.0.0.", category=DeprecationWarning)
def report_all(self, manager: ResultManager, title: str = "All tests results") -> Table:
    """Create a table report with all tests for one or all devices.

    Create table with full output: Device | Test Name | Test Status | Message(s) | Test description | Test category

    Warnings
    --------
    * This method sets the `report.title.all` value which impacts future calls to generate_* methods.

    Parameters
    ----------
    manager
        A ResultManager instance.
    title
        Title for the report. Defaults to 'All tests results'.

    Returns
    -------
    Table
        A fully populated rich `Table`.
    """
    self.title.all = title
    return self.generate(manager)

report_summary_devices deprecated

report_summary_devices(
    manager: ResultManager,
    devices: list[str] | None = None,
    title: str = "Summary per device",
) -> Table
Deprecated

This method is deprecated, use generate_summary_devices instead. This will be removed in ANTA v2.0.0.

Create a table report with result aggregated per device.

Create table with full output: Device | # of success | # of skipped | # of failure | # of errors | List of failed or error test cases

Warnings
  • This method sets the report.title.all value which impacts future calls to generate_* methods.

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required
devices list[str] | None

List of device names to include. None to select all devices.

None
title str

Title of the report.

'Summary per device'

Returns:

Type Description
Table

A fully populated rich Table.

Source code in anta/reporter/__init__.py
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
@deprecated("This method is deprecated, use `generate_summary_devices` instead. This will be removed in ANTA v2.0.0.", category=DeprecationWarning)
def report_summary_devices(
    self,
    manager: ResultManager,
    devices: list[str] | None = None,
    title: str = "Summary per device",
) -> Table:
    """Create a table report with result aggregated per device.

    Create table with full output: Device | # of success | # of skipped | # of failure | # of errors | List of failed or error test cases

    Warnings
    --------
    * This method sets the `report.title.all` value which impacts future calls to generate_* methods.

    Parameters
    ----------
    manager
        A ResultManager instance.
    devices
        List of device names to include. None to select all devices.
    title
        Title of the report.

    Returns
    -------
    Table
        A fully populated rich `Table`.
    """
    self.title.device = title
    return self.generate_summary_by_device(manager, devices=set(devices) if devices is not None else None)

report_summary_tests deprecated

report_summary_tests(
    manager: ResultManager,
    tests: list[str] | None = None,
    title: str = "Summary per test",
) -> Table
Deprecated

This method is deprecated, use generate_summary_tests instead. This will be removed in ANTA v2.0.0.

Create a table report with result aggregated per test.

Create table with full output: Test Name | # of success | # of skipped | # of failure | # of errors | List of failed or error nodes

Warnings
  • This method sets the report.title.all value which impacts future calls to generate_* methods.

Parameters:

Name Type Description Default
manager ResultManager

A ResultManager instance.

required
tests list[str] | None

List of test names to include. None to select all tests.

None
title str

Title of the report.

'Summary per test'

Returns:

Type Description
Table

A fully populated rich Table.

Source code in anta/reporter/__init__.py
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
@deprecated("This method is deprecated, use `generate_summary_tests` instead. This will be removed in ANTA v2.0.0.", category=DeprecationWarning)
def report_summary_tests(
    self,
    manager: ResultManager,
    tests: list[str] | None = None,
    title: str = "Summary per test",
) -> Table:
    """Create a table report with result aggregated per test.

    Create table with full output:
    Test Name | # of success | # of skipped | # of failure | # of errors | List of failed or error nodes

    Warnings
    --------
    * This method sets the `report.title.all` value which impacts future calls to generate_* methods.

    Parameters
    ----------
    manager
        A ResultManager instance.
    tests
        List of test names to include. None to select all tests.
    title
        Title of the report.

    Returns
    -------
    Table
        A fully populated rich `Table`.
    """
    self.title.tests = title
    return self.generate_summary_by_test(manager, tests=set(tests) if tests is not None else None)