[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/pythonnet/pythonnet/v3.2.0/src/embed_tests/TestCallbacks.cs [Back]  [Original]

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();
            }
        }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page