[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/pythonnet/pythonnet/just/src/embed_tests/TestNativeTypeOffset.cs [Back]  [Original]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

using NUnit.Framework;

using Python.Runtime;

namespace Python.EmbeddingTest
{
    public class TestNativeTypeOffset
    {
        /// 
        /// Tests that installation has generated code for NativeTypeOffset and that it can be loaded.
        ///         
        [Test]
        public void LoadNativeTypeOffsetClass()
        {
            PyObject sys = Py.Import("sys");
            // "m" is benign; "t" (free-threaded) is handled via ABI.ObjectHeadOffset
            // rather than the install-time-generated NativeTypeOffset class.
            var abiflags = sys.HasAttr("abiflags") ? sys.GetAttr("abiflags").ToString() : "";
            abiflags = abiflags.Replace("m", "").Replace("t", "");
            if (!string.IsNullOrEmpty(abiflags))
            {
                string typeName = "Python.Runtime.NativeTypeOffset, Python.Runtime";
                Assert.NotNull(Type.GetType(typeName), $"{typeName} does not exist and sys.abiflags={abiflags}");
            }
        }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page