summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuriy Taraday <yorik.sar@gmail.com>2017-06-29 16:01:32 +0400
committerYuriy Taraday <yorik.sar@gmail.com>2017-06-29 16:12:12 +0400
commitef7bfd577145483c91236df50f309f59b25ee4dc (patch)
treeafcf43426c298c70614d79cc158e43bd7d9afa85
parent555af4b91ba3ee398cdf884daf19ffb15f475c2f (diff)
downloadoslo-concurrency-ef7bfd577145483c91236df50f309f59b25ee4dc.tar.gz
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
-rw-r--r--oslo_concurrency/tests/unit/test_processutils.py17
1 files 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):