I have a regression test application, regression.py. But some of the tests depend on test_server.py being up and running.
At the moment I do this in regression.py’s main():
check_server()
...
def check_server():
reply = subprocess.run(['nc', '-vz', 'localhost', '5558'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
if reply.returncode != 0:
raise SystemExit('run: ./misc/test_server.py &')
However, I would far rather that check_server()
actually started the server. Of course, this is easy to do using subprocess.run()
or os.system()
; but in both cases the server is shutdown when regression.py finishes. I don’t want it to shutdown because I have other tests that also depend on the server.
So what I want is for each test to check .py to check if the server is running and if not, to start it once and for all, so that for all subsequent tests the server is running.