Skip to content

Commit

Permalink
test(robot-server): Pass along server subprocess's logs to pytest (#9947
Browse files Browse the repository at this point in the history
)
  • Loading branch information
SyntaxColoring authored Apr 13, 2022
1 parent 7d4258a commit 0e1f615
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions robot-server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ def run_server(
"OT_ROBOT_SERVER_DOT_ENV_PATH": "dev.env",
"OT_API_CONFIG_DIR": server_temp_directory,
},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
# The server will log to its stdout or stderr.
# Let it inherit our stdout and stderr so pytest captures its logs.
stdout=None,
stderr=None,
) as proc:
# Wait for a bit to get started by polling /health
from requests.exceptions import ConnectionError
Expand Down
10 changes: 6 additions & 4 deletions robot-server/tests/integration/dev_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def start(self) -> None:
"OT_API_CONFIG_DIR": self.server_temp_directory,
"OT_ROBOT_SERVER_persistence_directory": self.persistence_directory,
},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
# The server will log to its stdout or stderr.
# Let it inherit our stdout and stderr so pytest captures its logs.
stdout=None,
stderr=None,
)

def stop(self) -> None:
"""Stop the robot server."""
self.proc.send_signal(signal.SIGTERM)
# This calls proc.wait() and does cleanup on stdin, stdout and stderr.
self.proc.__exit__(None, None, None)
self.proc.wait()

0 comments on commit 0e1f615

Please sign in to comment.