green.subprocess: keep CalledProcessError identity
https://github.com/eventlet/eventlet/issues/413
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user