From ef7bfd577145483c91236df50f309f59b25ee4dc Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Thu, 29 Jun 2017 16:01:32 +0400 Subject: [PATCH] Check for SubprocessError by name on Python 3.x With eventlet SubprocessError raised by Popen seem to have different class from subprocess.SubprocessError accessible from test. I don't have proper solution for this, it seems somewhere old SubprocessError is cached and then eventlet overrides it, so it is not visible from test method context. This workaround seems to be good enough to unblock gate. Change-Id: If5ae0911e14671e05aca5e393c5cc183b72703d6 Closes-Bug: #1688201 --- .../tests/unit/test_processutils.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/oslo_concurrency/tests/unit/test_processutils.py b/oslo_concurrency/tests/unit/test_processutils.py index 33826b2..ae64af9 100644 --- a/oslo_concurrency/tests/unit/test_processutils.py +++ b/oslo_concurrency/tests/unit/test_processutils.py @@ -112,12 +112,17 @@ class UtilsTest(test_base.BaseTestCase): processutils.execute(TRUE_UTILITY) - expected_exception = (processutils.InvalidArgumentError if six.PY2 - else subprocess.SubprocessError) - self.assertRaises(expected_exception, - processutils.execute, - TRUE_UTILITY, - preexec_fn=preexec_fn) + if six.PY2: + self.assertRaises(processutils.InvalidArgumentError, + processutils.execute, + TRUE_UTILITY, + preexec_fn=preexec_fn) + else: + try: + processutils.execute(TRUE_UTILITY, preexec_fn=preexec_fn) + except Exception as e: + if type(e).__name__ != 'SubprocessError': + raise class ProcessExecutionErrorTest(test_base.BaseTestCase):