Skip to content

squape.video

remove_videos_on_success

remove_videos_on_success()

Remove all captured videos when the execution was successful (no failures)

Warning

Removing videos on success does not work with Squish 7.1.1 and below when execution is triggered outside the Squish IDE.

Source code in squape/video.py
132
133
134
135
136
137
138
139
140
141
142
def remove_videos_on_success() -> None:
    """
    Remove all captured videos when the execution was successful (no failures)

    !!! warning
        Removing videos on success does not work with Squish 7.1.1 and below
        when execution is triggered outside the Squish IDE.
    """
    if _failure_results_count() == 0:
        videos_to_remove = _videos_set()
        _replace_videos(videos_to_remove)

video_capture

video_capture(message='', remove_on_success=False)

Allows using Squish's video capture as context managers. https://doc.qt.io/squish/squish-api.html#test-startvideocapture-message Optionally (when the execution was successful) replace captured video with a tiny placeholder video to save test results size.

Warning

Removing videos on success does not work with Squish 7.1.1 and below when execution is triggered outside the Squish IDE.

Parameters:

Name Type Description Default
message str

log a video n the test report using the specified message. Defaulting to empty string.

''
remove_on_success bool

Whether to replace captured video when there were no failures. Defaulting to False.

False

Examples:

with video_capture(remove_on_success=True):
    # code with actions and verifications
Source code in squape/video.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@contextmanager
def video_capture(message: str = "", remove_on_success: bool = False) -> None:
    """Allows using Squish's video capture as context managers.
    https://doc.qt.io/squish/squish-api.html#test-startvideocapture-message
    Optionally (when the execution was successful) replace captured video
    with a tiny placeholder video to save test results size.

    !!! warning
        Removing videos on success does not work with Squish 7.1.1 and below
        when execution is triggered outside the Squish IDE.

    Args:
        message (str): log a video n the test report using the specified message.
            Defaulting to empty string.
        remove_on_success (bool): Whether to replace captured video
            when there were no failures. Defaulting to False.

    Examples:
        ```python
        with video_capture(remove_on_success=True):
            # code with actions and verifications
        ```
    """

    if remove_on_success:
        initial_videos = _videos_set()
        initial_result_count = _failure_results_count()

    test.startVideoCapture(message)

    try:
        yield
    except Exception:
        raise
    finally:
        test.stopVideoCapture(message)

        if remove_on_success:
            new_failures = _failure_results_count() - initial_result_count
            if new_failures == 0:
                new_videos = _videos_set() - initial_videos
                _replace_videos(new_videos)