Skip to content

Commit

Permalink
green.subprocess: keep CalledProcessError identity
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed May 15, 2017
1 parent 0ec4df6 commit b9cc871
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions eventlet/green/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ def patched_function(function):
__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
subprocess_imported = sys.modules['subprocess']
CalledProcessError = subprocess_imported.CalledProcessError
del subprocess_imported
12 changes: 12 additions & 0 deletions tests/isolated/subprocess_exception_identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
__test__ = False

if __name__ == '__main__':
import subprocess as original
from eventlet.green import subprocess as green

cases = (
'CalledProcessError',
)
for c in cases:
assert getattr(green, c) is getattr(original, c), c
print('pass')
6 changes: 6 additions & 0 deletions tests/subprocess_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,9 @@ 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
tests.run_isolated('subprocess_exception_identity.py')

0 comments on commit b9cc871

Please sign in to comment.