Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Add test for with + exception combo #887

Merged
merged 1 commit into from
Aug 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/structures/test_with.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from ..utils import TranspileTestCase

from unittest import expectedFailure


class WithLoopTests(TranspileTestCase):
def test_with(self):
Expand Down Expand Up @@ -37,6 +39,23 @@ def __exit__(self, exc_type, exc_value, traceback):
raise KeyError('ola')
""", exits_early=True)

@expectedFailure
def test_with_suppresses_exception(self):
self.assertCodeExecution("""
class CtxMgr:
def __enter__(self):
print('entering CtxMgr')
def __exit__(self, exc_type, exc_value, traceback):
print('exiting CtxMgr')
print('exc_value', exc_value)
return True
with CtxMgr():
raise KeyError('ola')
print('Done')
""")

def test_with_noexit(self):
self.assertCodeExecution("""
class CtxMgrMissingExit:
Expand Down