Skip to content

Commit c5bbb00

Browse files
authored
Fix test util typings (#437)
1 parent dea5674 commit c5bbb00

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

jupyterlab_server/test_utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def __init__(self, request: HTTPRequest, spec: Spec):
6060
path=path,
6161
)
6262

63+
@property
64+
def content_type(self) -> str:
65+
return "application/json"
66+
6367
@property
6468
def host_url(self) -> str:
6569
url = self.request.url
@@ -95,13 +99,13 @@ def method(self) -> str:
9599
return method and method.lower() or ""
96100

97101
@property
98-
def body(self) -> str | None:
102+
def body(self) -> bytes | None:
99103
if self.request.body is None:
100104
return None # type:ignore[unreachable]
101105
if not isinstance(self.request.body, bytes):
102106
msg = "Request body is invalid" # type:ignore[unreachable]
103107
raise AssertionError(msg)
104-
return self.request.body.decode("utf-8")
108+
return self.request.body
105109

106110
@property
107111
def mimetype(self) -> str:
@@ -123,16 +127,20 @@ def __init__(self, response: HTTPResponse):
123127
self.response = response
124128

125129
@property
126-
def data(self) -> str:
130+
def data(self) -> bytes | None:
127131
if not isinstance(self.response.body, bytes):
128132
msg = "Response body is invalid" # type:ignore[unreachable]
129133
raise AssertionError(msg)
130-
return self.response.body.decode("utf-8")
134+
return self.response.body
131135

132136
@property
133137
def status_code(self) -> int:
134138
return int(self.response.code)
135139

140+
@property
141+
def content_type(self) -> str:
142+
return "application/json"
143+
136144
@property
137145
def mimetype(self) -> str:
138146
return str(self.response.headers.get("Content-Type", "application/json"))

0 commit comments

Comments
 (0)