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
This commit is contained in:
parent
555af4b91b
commit
ef7bfd5771
@ -112,12 +112,17 @@ class UtilsTest(test_base.BaseTestCase):
|
|||||||
|
|
||||||
processutils.execute(TRUE_UTILITY)
|
processutils.execute(TRUE_UTILITY)
|
||||||
|
|
||||||
expected_exception = (processutils.InvalidArgumentError if six.PY2
|
if six.PY2:
|
||||||
else subprocess.SubprocessError)
|
self.assertRaises(processutils.InvalidArgumentError,
|
||||||
self.assertRaises(expected_exception,
|
processutils.execute,
|
||||||
processutils.execute,
|
TRUE_UTILITY,
|
||||||
TRUE_UTILITY,
|
preexec_fn=preexec_fn)
|
||||||
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):
|
class ProcessExecutionErrorTest(test_base.BaseTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user