Skip to content

Commit

Permalink
Enable test_contextlib
Browse files Browse the repository at this point in the history
  • Loading branch information
slozier committed Mar 20, 2021
1 parent ef9a15e commit f08b0de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ public BaseException? __context__ {
get {
return _context ?? __cause__;
}
internal set {
_context = value;
}
}

public bool __suppress_context__ { get; set; }
Expand Down Expand Up @@ -365,7 +362,7 @@ protected internal virtual void InitializeFromClr(System.Exception/*!*/ exceptio

internal Exception CreateClrExceptionWithCause(BaseException? cause, BaseException? context, bool suppressContext) {
_cause = cause;
_context = context;
if (context != this) _context = context;
__suppress_context__ = suppressContext;
_traceback = null;

Expand Down
7 changes: 2 additions & 5 deletions Src/IronPythonTest/Cases/CPythonCasesManifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Reason=ImportError: No module named audioop
Ignore=true

[CPython.test_binhex]
Ignore=true
Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/673

[CPython.test_builtin] # IronPython.test_builtin_stdlib
Ignore=true
Expand Down Expand Up @@ -297,10 +297,6 @@ Ignore=true
Ignore=true
Reason=ImportError: Cannot import name SemLock

[CPython.test_contextlib]
Ignore=true
Reason=Hangs

[CPython.test_copy]
IsolationLevel=ENGINE
MaxRecursion=100
Expand Down Expand Up @@ -661,6 +657,7 @@ Ignore=true
Reason=unittest.case.SkipTest: No module named 'nis'

[CPython.test_nntplib]
Ignore=true # currently failing in CI
RunCondition=NOT $(IS_NETCOREAPP) # https://github.com/IronLanguages/ironpython3/issues/1058

[CPython.test_normalization]
Expand Down
29 changes: 25 additions & 4 deletions Tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ def test_finally_continue_nested_finally_fails(self):
finally:
continue
'''
try:
with self.assertRaises(SyntaxError):
compile(t, '<test>', 'exec')
self.fail("Should raise SyntaxError")
except SyntaxError:
pass

def test_bigint_division(self):
def divide(a, b):
Expand Down Expand Up @@ -1046,4 +1043,28 @@ def f():

self.assertRaises(error, f)

def test_reraise_context(self):
# reraising an exception should preserve the context
ex1 = Exception(1)
try:
try:
raise ex1
except:
raise ex1
except Exception as e:
self.assertIsNone(e.__context__)

ex1 = Exception(1)
ex2 = Exception(2)
try:
try:
try:
raise ex2
except:
raise ex1
except:
raise ex1
except Exception as e:
self.assertIs(e.__context__, ex2)

run_test(__name__)

0 comments on commit f08b0de

Please sign in to comment.