green.subprocess: keep CalledProcessError identity

https://github.com/eventlet/eventlet/issues/413
This commit is contained in:
Sergey Shepelev
2017-05-14 13:31:47 +03:00
parent 0ec4df6cbe
commit eac49d80bb
2 changed files with 14 additions and 0 deletions

View File

@@ -133,3 +133,7 @@ if hasattr(subprocess_orig, 'check_output'):
__patched__.append('check_output')
check_output = patched_function(subprocess_orig.check_output)
del patched_function
# Keep exceptions identity.
# https://github.com/eventlet/eventlet/issues/413
CalledProcessError = subprocess_orig.CalledProcessError

View File

@@ -93,3 +93,13 @@ def test_check_call_without_timeout_works():
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
def test_exception_identity():
# https://github.com/eventlet/eventlet/issues/413
# green module must keep exceptions classes as stdlib version
cases = (
'CalledProcessError',
)
for c in cases:
assert getattr(subprocess, c) is getattr(original_subprocess, c), c