weixin_39647787 2020-11-22 03:16
浏览 0

assertRaises ignores CLR exceptions

From on December 9, 2014 17:52

IronPython 2.7 Beta 2 fails to catch CLR exceptions in assertRaises. The attached patch fixes the issue.

prompt% cat spam.py
"""This file is spam.py."""
import unittest
from System import InvalidOperationException
class Issue(unittest.TestCase):


def test_assertRaises(self):
    with self.assertRaises(InvalidOperationException):
        raise InvalidOperationException('assertRaises should catch this')

prompt% ipy -m unittest spam

E

ERROR: test_assertRaises (spam.Issue)

Traceback (most recent call last):
File "C:\cygwin\home\Johiga\qmdl_test\spam.py", line 6, in test_assertRaises


raise InvalidOperationException('assertRaises should catch this')

SystemError: assertRaises should catch this

Ran 1 test in 0.078s

FAILED (errors=1)

Work Item Details

Original CodePlex Issue: Issue 30119 Status: Active Reason Closed: Unassigned Assigned to: jdhardy Reported on: Feb 8, 2011 at 1:10 AM Reported by: jonathanhiga Updated on: Sep 12 at 1:14 PM Updated by: slide_o_mix

Plaintext Attachments

CodePlex Issue #30119 Plain Text Attachments

Copied from original issue: IronLanguages/main#919

该提问来源于开源项目:IronLanguages/ironpython2

  • 写回答

5条回答 默认 最新

  • weixin_39647787 2020-11-22 03:16
    关注

    From on December 9, 2014 17:52

    On 2011-02-08 09:15:28 UTC, jonathanhiga commented:

    Attached spam.py since the formatting in the textarea element looks unpythonic.

    评论

报告相同问题?