Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0961c94

Browse files
committed
added tests for __cause__/InnerException#893#1098
1 parentbec8b7d commit0961c94

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎src/embed_tests/TestPythonException.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ public void TestPythonErrorTypeName()
5555
}
5656
}
5757

58+
[Test]
59+
publicvoidTestNestedExceptions()
60+
{
61+
try
62+
{
63+
PythonEngine.Exec(@"
64+
try:
65+
raise Exception('inner')
66+
except Exception as ex:
67+
raise Exception('outer') from ex
68+
");
69+
}
70+
catch(PythonExceptionex)
71+
{
72+
Assert.That(ex.InnerException,Is.InstanceOf<PythonException>());
73+
Assert.That(ex.InnerException.Message,Is.EqualTo("Exception : inner"));
74+
}
75+
}
76+
77+
[Test]
78+
publicvoidInnerIsEmptyWithNoCause()
79+
{
80+
varlist=newPyList();
81+
PyObjectfoo=null;
82+
83+
varex=Assert.Throws<PythonException>(()=>foo=list[0]);
84+
85+
Assert.IsNull(ex.InnerException);
86+
}
87+
5888
[Test]
5989
publicvoidTestPythonExceptionFormat()
6090
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp