Class: QgsLayoutChecker¶
Renders a layout to an image and compares with an expected output.
Class Hierarchy¶
Base classes¶
Allows checking rendered images against comparison images. |
Methods
Sets the output (reference) image size. |
|
Runs a render check on the layout, adding results to the specified report. |
- class qgis.core.QgsLayoutChecker[source]¶
Bases:
QgsMultiRenderChecker
- __init__(testName: str | None, layout: QgsLayout | None)
Constructor for QgsLayoutChecker.
- Parameters:
testName (Optional[str])
layout (Optional[QgsLayout])
- __init__(a0: QgsLayoutChecker)
- Parameters:
a0 (QgsLayoutChecker)
- setSize(self, size: QSize)[source]¶
Sets the output (reference) image
size
.- Parameters:
size (QSize)
- testLayout(self, page: int = 0, pixelDiff: int = 0, createReferenceImage: bool = False)[source]¶
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
toTrue
in this case the test will always returnTrue
.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) -> (bool) – if
True
, the rendered reference image will be regenerated instead of performing a comparison test with the existing image
- Returns:
True
if the rendered layout matches the expected reference image.report: generated test report