Skip to content

Commit ba97ef5

Browse files
committed
test
1 parent 211c034 commit ba97ef5

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

tests/test_server.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from functools import partial
77
from pathlib import Path
8-
from typing import Any, Iterator, List, Optional, cast
8+
from typing import Any, Iterator, List, Optional, Union, cast
99

1010
import grpc
1111
import pytest
@@ -118,7 +118,7 @@ def define_environment(kind: str, **kwargs: Any) -> definitions.EnvironmentDefin
118118

119119
def run_request(
120120
stub: definitions.IsolateStub,
121-
request: definitions.BoundFunction,
121+
request: Union[definitions.BoundFunction, definitions.RunRequest],
122122
*,
123123
build_logs: Optional[List[Log]] = None,
124124
bridge_logs: Optional[List[Log]] = None,
@@ -270,6 +270,50 @@ def test_user_logs_immediate(stub: definitions.IsolateStub, monkeypatch: Any) ->
270270
assert by_stream[LogLevel.STDERR] == "error error!"
271271

272272

273+
def test_no_stream_logs(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
274+
inherit_from_local(monkeypatch)
275+
276+
env_definition = define_environment("virtualenv", requirements=["pyjokes==0.6.0"])
277+
request = definitions.RunRequest(
278+
function=definitions.BoundFunction(
279+
function=to_serialized_object(
280+
partial(
281+
exec,
282+
textwrap.dedent(
283+
"""
284+
import sys, pyjokes
285+
print(pyjokes.__version__)
286+
print("error error!", file=sys.stderr)
287+
"""
288+
),
289+
),
290+
method="dill",
291+
),
292+
environments=[env_definition],
293+
),
294+
metadata=definitions.TaskMetadata(
295+
logger_labels={},
296+
# the default is True
297+
stream_logs=False,
298+
),
299+
)
300+
301+
user_logs: List[Log] = []
302+
build_logs: List[Log] = []
303+
bridge_logs: List[Log] = []
304+
run_request(
305+
stub,
306+
request,
307+
user_logs=user_logs,
308+
build_logs=build_logs,
309+
bridge_logs=bridge_logs,
310+
)
311+
312+
assert len(user_logs) == 0
313+
assert len(build_logs) == 0
314+
assert len(bridge_logs) == 0
315+
316+
273317
def test_unknown_environment(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
274318
inherit_from_local(monkeypatch)
275319

0 commit comments

Comments
 (0)