aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-05-23 15:16:23 -0700
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-05-23 15:16:23 -0700
commit95e513f95a39756dc930c056aee6d7ea1b96c8cc (patch)
tree487768c005030d89dc2a6f9a1727109ebed6687d /tests
parent40226370b428e6ba0a4bb8517f00e42807cae894 (diff)
downloadcryptography-95e513f95a39756dc930c056aee6d7ea1b96c8cc.tar.gz
cryptography-95e513f95a39756dc930c056aee6d7ea1b96c8cc.tar.bz2
cryptography-95e513f95a39756dc930c056aee6d7ea1b96c8cc.zip
Close stdout and stderr when spawning a process (#3578)
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/backends/test_openssl_memleak.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py
index e4cbd0fb..53c41375 100644
--- a/tests/hazmat/backends/test_openssl_memleak.py
+++ b/tests/hazmat/backends/test_openssl_memleak.py
@@ -102,15 +102,19 @@ def assert_no_memory_leaks(s, argv=[]):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
- proc.wait()
- if proc.returncode == 255:
- # 255 means there was a leak, load the info about what mallocs weren't
- # freed.
- out = json.loads(proc.stdout.read().decode())
- raise AssertionError(out)
- elif proc.returncode != 0:
- # Any exception type will do to be honest
- raise ValueError(proc.stdout.read(), proc.stderr.read())
+ try:
+ proc.wait()
+ if proc.returncode == 255:
+ # 255 means there was a leak, load the info about what mallocs
+ # weren't freed.
+ out = json.loads(proc.stdout.read().decode())
+ raise AssertionError(out)
+ elif proc.returncode != 0:
+ # Any exception type will do to be honest
+ raise ValueError(proc.stdout.read(), proc.stderr.read())
+ finally:
+ proc.stdout.close()
+ proc.stderr.close()
def skip_if_memtesting_not_supported():