def test_file_cast(app: Sanic):
    """Tests that the list of files in a sanic Request gets correctly turned into a dictionary"""
    from sanic.request import File
    from strawberry.sanic import utils

    file_name = "test.txt"

    file_content = b"Hello, there!."
    in_memory_file = BytesIO(file_content)
    in_memory_file.name = file_name

    form_data = {
        "operations": '{ "query": "mutation($file: Upload!){ fileUpload(file: $file) }", "variables": { "file": null } }',
        "map": '{ "file": ["variables.file"] }',
    }

    files = {
        "file": in_memory_file,
    }

    request, _ = app.test_client.post("/graphql", data=form_data, files=files)

    files = utils.convert_request_to_files_dict(request)  # type: ignore
    file = files["file"]

    assert isinstance(file, File)
    assert file.name == file_name
    assert file.body == file_content
Tests that the list of files in a sanic Request gets correctly turned into a dictionary
tests/sanic/test_file_upload.py