1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
From: Sebastian Ramacher <sramacher@debian.org>
Date: Mon, 16 Apr 2018 01:02:09 +0200
Subject: Fix handling of the output stream in SelfTest
Last-Update: 2014-01-23
Forwarded: https://github.com/dlitz/pycrypto/pull/39
Applied-Upstream: yes
---
lib/Crypto/SelfTest/__init__.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/Crypto/SelfTest/__init__.py b/lib/Crypto/SelfTest/__init__.py
index 40b3969..7110cd2 100644
--- a/lib/Crypto/SelfTest/__init__.py
+++ b/lib/Crypto/SelfTest/__init__.py
@@ -66,11 +66,13 @@ def run(module=None, verbosity=0, stream=None, tests=None, config=None, **kwargs
raise ValueError("'module' and 'tests' arguments are mutually exclusive")
if stream is None:
kwargs['stream'] = StringIO()
+ else:
+ kwargs['stream'] = stream
runner = unittest.TextTestRunner(verbosity=verbosity, **kwargs)
result = runner.run(suite)
if not result.wasSuccessful():
if stream is None:
- sys.stderr.write(stream.getvalue())
+ sys.stderr.write(kwargs['stream'].getvalue())
raise SelfTestError("Self-test failed", result)
return result
|