Skip to content

Commit

Permalink
added tests for __cause__/InnerException #893 #1098
Browse files Browse the repository at this point in the history
  • Loading branch information
lostmsu committed May 6, 2020
1 parent 89d7a6a commit 4fe0548
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/embed_tests/TestPythonException.cs
Expand Up @@ -55,6 +55,36 @@ public void TestPythonErrorTypeName()
}
}

[Test]
public void TestNestedExceptions()
{
try
{
PythonEngine.Exec(@"
try:
raise Exception('inner')
except Exception as ex:
raise Exception('outer') from ex
");
}
catch (PythonException ex)
{
Assert.That(ex.InnerException, Is.InstanceOf<PythonException>());
Assert.That(ex.InnerException.Message, Is.EqualTo("Exception : inner"));
}
}

[Test]
public void InnerIsEmptyWithNoCause()
{
var list = new PyList();
PyObject foo = null;

var ex = Assert.Throws<PythonException>(() => foo = list[0]);

Assert.IsNull(ex.InnerException);
}

[Test]
public void TestPythonExceptionFormat()
{
Expand Down

0 comments on commit 4fe0548

Please sign in to comment.