code: def test_max_csv_mb(app_client_csv_max_mb_one):
      # This query deliberately generates a really long string
      # should be 100*100*100*2 = roughly 2MB
      response = app_client_csv_max_mb_one.get(
          "/fixtures.csv?"
          + urllib.parse.urlencode(
              {
                  "sql": """
              select group_concat('ab', '')
              from json_each(json_array({lots})),
                  json_each(json_array({lots})),
                  json_each(json_array({lots}))
              """.format(
                      lots=", ".join(str(i) for i in range(100))
                  ),
                  "_stream": 1,
                  "_size": "max",
              }
          ),
      )
      # It's a 200 because we started streaming before we knew the error
      assert response.status == 200
      # Last line should be an error message
      last_line = [
          line for line in response.body.split(b"\r\n") if line
      ][-1]
      assert last_line.startswith(b"CSV contains more than")
  
file_path: datasette/tests/test_csv.py
imports: from datasette.app import Datasette
  from bs4 import BeautifulSoup
  import pytest
  from .fixtures import app_client, app_client_csv_max_mb_one, app_client_with_cors, app_client_with_trace
  import urllib.parse
label_desc: Use image node_id 2 for calling a global function with example usage: test_max_csv_mb(app_client_csv_max_mb_one) without return types