Skip to content

Commit

Permalink
Fix unexpected bug in exiting hook context manager (#18014)
Browse files Browse the repository at this point in the history
  • Loading branch information
malthe committed Sep 3, 2021
1 parent a88115e commit 9c64419
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airflow/providers/microsoft/psrp/hooks/psrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __enter__(self):

def __exit__(self, exc_type, exc_value, traceback):
try:
self._client.__exit__()
self._client.__exit__(exc_type, exc_value, traceback)
finally:
self._client = None

Expand Down
2 changes: 2 additions & 0 deletions tests/providers/microsoft/psrp/hooks/test_psrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def end_invoke():

hook.invoke_powershell("foo")

assert ws_man().__exit__.mock_calls == [call(None, None, None)]

assert call('%s', '<output>') in log_info.mock_calls
assert call('Information: %s', '<message>') in log_info.mock_calls
assert call('Invocation state: %s', 'Completed') in log_info.mock_calls

0 comments on commit 9c64419

Please sign in to comment.