mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-04 12:14:11 +00:00
handle more inputs in test body-producer
This commit is contained in:
parent
0f4201ef19
commit
0e5422c24b
@ -16,6 +16,7 @@ from twisted.internet.defer import (
|
|||||||
|
|
||||||
from treq.client import (
|
from treq.client import (
|
||||||
HTTPClient,
|
HTTPClient,
|
||||||
|
FileBodyProducer,
|
||||||
)
|
)
|
||||||
from treq.testing import (
|
from treq.testing import (
|
||||||
RequestTraversalAgent,
|
RequestTraversalAgent,
|
||||||
@ -192,9 +193,12 @@ class _SynchronousProducer(object):
|
|||||||
"""
|
"""
|
||||||
Create a synchronous producer with some bytes.
|
Create a synchronous producer with some bytes.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(body, FileBodyProducer):
|
||||||
|
body = body._inputFile.read()
|
||||||
|
|
||||||
if not isinstance(body, bytes):
|
if not isinstance(body, bytes):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"'body' must be bytes"
|
"'body' must be bytes not '{}'".format(type(body))
|
||||||
)
|
)
|
||||||
self.body = body
|
self.body = body
|
||||||
self.length = len(body)
|
self.length = len(body)
|
||||||
|
Loading…
Reference in New Issue
Block a user