diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2017-09-21 15:52:51 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2017-09-27 18:19:03 +0200 |
commit | eae356d823b5d7d8d1e21bb707c0d9fddb78a8d9 (patch) | |
tree | e65d195e8aa363fca7d9e14f933ad1cf3da4bc80 /tests/test_ssl.py | |
parent | 66579713779f17c5fce9013ad3b0def154fd8042 (diff) | |
download | m2crypto-eae356d823b5d7d8d1e21bb707c0d9fddb78a8d9.tar.gz |
Don’t do fork/exec manually, but use subprocess.Popen for tests.
Diffstat (limited to 'tests/test_ssl.py')
-rw-r--r-- | tests/test_ssl.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 94de47a..33fbd7c 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -21,8 +21,10 @@ Others: """ import logging import os +import os.path import signal import socket +import subprocess import sys import tempfile import time @@ -112,23 +114,17 @@ class BaseSSLClientTestCase(unittest.TestCase): if not self.openssl_in_path: raise Exception('openssl command not in PATH') - pid = os.fork() - if pid == 0: - # openssl must be started in the tests directory for it - # to find the .pem files - os.chdir('tests') - try: - os.execvp('openssl', args) - finally: - os.chdir('..') - - else: - time.sleep(sleepTime) - return pid + pid = subprocess.Popen(['openssl'] + args, + cwd='tests', + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + time.sleep(sleepTime) + return pid def stop_server(self, pid): - os.kill(pid, signal.SIGTERM) - os.waitpid(pid, 0) + pid.terminate() + out, err = pid.communicate() + return out, err def http_get(self, s): s.send('GET / HTTP/1.0\n\n') |