X Tutup
using System; using NUnit.Framework; using Python.Runtime; namespace Python.EmbeddingTest { public class TestCallbacks { [Test] public void TestNoOverloadException() { int passed = 0; var aFunctionThatCallsIntoPython = new Action(value => passed = value); using (Py.GIL()) { using dynamic callWith42 = PythonEngine.Eval("lambda f: f([42])"); using var pyFunc = aFunctionThatCallsIntoPython.ToPython(); var error = Assert.Throws(() => callWith42(pyFunc)); Assert.That(error.Type.Name, Is.EqualTo("TypeError")); string expectedArgTypes = "()"; StringAssert.EndsWith(expectedArgTypes, error.Message); error.Traceback.Dispose(); } } } }
X Tutup