Repository: ManimCommunity/manim
File: tests/test_graphical_units/testing/frames_comparison.py (Python)

Code before:
    module_name: str,
    last_frame: bool = True,
    renderer_class=CairoRenderer,
    base_scene=Scene,
    **custom_config,
):
    """Compares the frames generated by the test with control frames specified with the test_name and module_name.

    If there is no control frames for this test, the test will fail. To generate control frames for a given test, pass `--set_test` flag to pytest while running the test.

    Parameters
    ----------
    test_name : str
        The name of the test.
    module_name : str
        The module which the test belongs to.
    last_frame : bool, optional
        whether the test should test the last frame, by default True.
    renderer_class , optional
        The base renderer to use (OpenGlRenderer/CairoRenderer), by default CairoRenderer
    base_scene : [type], optional
        The base class for the scene (ThreeDScene, etc.), by default Scene

    .. warning::
        By default, last_frame is True, which means that only the last frame is tested.
        If the scene has a moving animation, then the test must have last_frame = False.
    """

    def decorator(tested_scene_construct):
        # Exclude "scene" from the argument list of the signature.
        old_sig = inspect.signature(
            functools.partial(tested_scene_construct, scene=None)
        )

        if (
            SCENE_PARAMETER_NAME
            not in inspect.getfullargspec(tested_scene_construct).args
        ):
            raise Exception(
                f"Invalid graphical test function test function : must have '{SCENE_PARAMETER_NAME}'as one of the parameters."
            )

        @functools.wraps(tested_scene_construct)
        # The "request" parameter is meant to be used as a fixture by pytest. See below.
        def wrapper(*args, request: FixtureRequest, tmp_path, **kwargs):
            # Wraps the test_function to a construct method, to "freeze" the eventual additional arguments (parametrizations fixtures).
            construct = functools.partial(tested_scene_construct, *args, **kwargs)

            # Kwargs contains the eventual parametrization arguments.
            # This modify the test_name so the it is defined by the parametrization arguments too.
            # Ex : if "length" is parametrized from 0 to 20, the kwargs will be with once with {"length" : 1}, etc.

Review comment (suggestion):
Language

```suggestion
        If the scene has a moving animation, then the test must set last_frame to False.
```

Code after:
    renderer_class=CairoRenderer,
    base_scene=Scene,
    **custom_config,
):
    """Compares the frames generated by the test with control frames
    specified with the ``test_name`` and ``module_name``.

    If there is no control frames for this test, the test will fail. To generate
    control frames for a given test, pass ``--set_test`` flag to pytest
    while running the test.

    Parameters
    ----------
    test_name
        The name of the test.
    module_name
        The module which the test belongs to.
    last_frame
        whether the test should test the last frame, by default True.
    renderer_class
        The base renderer to use (OpenGLRenderer/CairoRenderer), by default CairoRenderer
    base_scene
        The base class for the scene (ThreeDScene, etc.), by default Scene

    .. warning::
        By default, last_frame is True, which means that only the last frame is tested.
        If the scene has a moving animation, then the test must set last_frame to False.
    """

    def decorator(tested_scene_construct):
        if (
            SCENE_PARAMETER_NAME
            not in inspect.getfullargspec(tested_scene_construct).args
        ):
            raise Exception(
                f"Invalid graphical test function test function : must have '{SCENE_PARAMETER_NAME}'as one of the parameters."
            )

        # Exclude "scene" from the argument list of the signature.
        old_sig = inspect.signature(
            functools.partial(tested_scene_construct, scene=None)
        )

        @functools.wraps(tested_scene_construct)
        # The "request" parameter is meant to be used as a fixture by pytest. See below.
        def wrapper(*args, request: FixtureRequest, tmp_path, **kwargs):
            # Wraps the test_function to a construct method, to "freeze" the eventual additional arguments (parametrizations fixtures).
            construct = functools.partial(tested_scene_construct, *args, **kwargs)

            # Kwargs contains the eventual parametrization arguments.
            # This modify the test_name so the it is defined by the parametrization arguments too.