Class: QgsLayoutChecker

class qgis.core.QgsLayoutChecker

Bases: QgsMultiRenderChecker

Renders a layout to an image and compares with an expected output

QgsLayoutChecker(testName: str, layout: QgsLayout) Constructor for QgsLayoutChecker.

QgsLayoutChecker(QgsLayoutChecker)

Methods

setSize

Sets the output (reference) image size.

testLayout

Runs a render check on the layout, adding results to the specified report.

setSize(self, size: QSize)

Sets the output (reference) image size.

Parameters:

size (QSize) –

testLayout(self, page: int = 0, pixelDiff: int = 0, createReferenceImage: bool = False) Tuple[bool, str]

Runs a render check on the layout, adding results to the specified report.

The maximum number of allowable pixels differing from the reference image is specified via the pixelDiff argument.

A reference image can be created by setting createReferenceImage to True in this case the test will always return True.

The page number is specified via page, where 0 corresponds to the first page in the layout.

Parameters:
  • page (int = 0) – page number from layout to render and check

  • pixelDiff (int = 0) – number of pixels which are permitted to differ from reference image.

  • createReferenceImage (bool = False) – if True, the rendered reference image will be regenerated instead of performing a comparison test with the existing image

Return type:

Tuple[bool, str]

Returns:

  • True if the rendered layout matches the expected reference image.

  • report: will be set to generated test report