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

Commit

Permalink
Merge pull request #887 from patiences/886-test
Browse files Browse the repository at this point in the history
Add test for with + exception combo
  • Loading branch information
freakboy3742 authored Aug 2, 2018
2 parents d26e35d + 28443fc commit b32bc31
Showing 1 changed file with 19 additions and 0 deletions.
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

0 comments on commit b32bc31

Please sign in to comment.