[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/pythonnet/pythonnet/net8.0/src/embed_tests/ExtensionTypes.cs [Back]  [Original]

using System;

using NUnit.Framework;

using Python.Runtime;

namespace Python.EmbeddingTest;

public class ExtensionTypes
{
    [OneTimeSetUp]
    public void SetUp()
    {
        PythonEngine.Initialize();
    }

    [OneTimeTearDown]
    public void Dispose()
    {
        PythonEngine.Shutdown();
    }

    [Test]
    public void WeakrefIsNone_AfterBoundMethodIsGone()
    {
        using var makeref = Py.Import("weakref").GetAttr("ref");
        var boundMethod = new UriBuilder().ToPython().GetAttr(nameof(UriBuilder.GetHashCode));
        var weakref = makeref.Invoke(boundMethod);
        boundMethod.Dispose();
        Assert.IsTrue(weakref.Invoke().IsNone());
    }
}

Web Proxy Viewer  |  New URL  |  Original Page