Skip to content

FletTestApp

FletTestApp #

page #

page: Page

Returns an instance of Flet's app Page.

pixel_ratio #

pixel_ratio = float(
    getenv(
        "FLET_TEST_SCREENSHOTS_PIXEL_RATIO",
        DEFAULT_SCREENSHOTS_PIXEL_RATIO,
    )
)

similarity_threshold #

similarity_threshold = float(
    getenv(
        "FLET_TEST_SIMILARITY_THRESHOLD",
        DEFAULT_SIMILARITY_THRESHOLD,
    )
)

tester #

tester: Tester

Returns an instance of Tester class that programmatically interacts with page controls and the test environment.

assert_control_screenshot #

assert_control_screenshot(
    name: str,
    control: Control,
    pump_times: int = 0,
    pump_duration: DurationValue | None = None,
)

Adds control to a clean page, takes a screenshot and compares it with a golden copy or takes golden screenshot if FLET_TEST_GOLDEN=1 environment variable is set.

PARAMETER DESCRIPTION
name

Screenshot name - will be used as a base for a screenshot filename.

TYPE: str

control

Control to take a screenshot of.

TYPE: Control

assert_screenshot #

assert_screenshot(name: str, screenshot: bytes)

Compares provided screenshot with a golden copy or takes golden screenshot if FLET_TEST_GOLDEN=1 environment variable is set.

PARAMETER DESCRIPTION
name

Screenshot name - will be used as a base for a screenshot filename.

TYPE: str

screenshot

Screenshot contents in PNG format.

TYPE: bytes

start #

start()

Starts Flet app and Flutter integration test process.

teardown #

teardown()

Teardown Flutter integration test process.