MCPcopy
hub / github.com/pallets/werkzeug / test_range_request_with_complete_file

Function test_range_request_with_complete_file

tests/test_wrappers.py:651–666  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

649
650
651def test_range_request_with_complete_file():
652 env = create_environ()
653 resources = os.path.join(os.path.dirname(__file__), "res")
654 fname = os.path.join(resources, "test.txt")
655 with open(fname, "rb") as f:
656 fcontent = f.read()
657 with open(fname, "rb") as f:
658 fsize = os.path.getsize(fname)
659 response = wrappers.Response(wrap_file(env, f))
660 env["HTTP_RANGE"] = f"bytes=0-{fsize - 1}"
661 response.make_conditional(env, accept_ranges=True, complete_length=fsize)
662 assert response.status_code == 206
663 assert response.headers["Accept-Ranges"] == "bytes"
664 assert response.headers["Content-Range"] == f"bytes 0-{fsize - 1}/{fsize}"
665 assert response.headers["Content-Length"] == str(fsize)
666 assert response.data == fcontent
667
668
669@pytest.mark.parametrize("value", [None, 0])

Callers

nothing calls this directly

Calls 4

make_conditionalMethod · 0.95
create_environFunction · 0.90
wrap_fileFunction · 0.90
readMethod · 0.45

Tested by

no test coverage detected