From 38e714f229c4fdb3de35edc36f78b141eccddfa1 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 22 Jul 2020 16:24:21 +0200 Subject: [PATCH] test/monitor: use osbuild.api.setup_stdio Use the new `api.setup_stdio` instead of providing an exact copy of that in the test code. --- test/mod/test_monitor.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/test/mod/test_monitor.py b/test/mod/test_monitor.py index f13934ec..02cbceae 100644 --- a/test/mod/test_monitor.py +++ b/test/mod/test_monitor.py @@ -15,23 +15,9 @@ import osbuild import osbuild.meta from osbuild.api import API from osbuild.monitor import LogMonitor -from osbuild.util import jsoncomm from .. import test -def setup_stdio(path): - """Copy of what the osbuild runners do to setup stdio""" - with jsoncomm.Socket.new_client(path) as client: - req = {'method': 'setup-stdio'} - client.send(req) - msg, fds, _ = client.recv() - for sio in ['stdin', 'stdout', 'stderr']: - target = getattr(sys, sio) - source = fds[msg[sio]] - os.dup2(source, target.fileno()) - fds.close() - - def echo(path): """echo stdin to stdout after setting stdio up via API @@ -39,7 +25,7 @@ def echo(path): simulating an osbuild runner and a stage run which does nothing but returns the supplied options to stdout again. """ - setup_stdio(path) + osbuild.api.setup_stdio(path) data = json.load(sys.stdin) json.dump(data, sys.stdout) sys.exit(0)