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

using System.Linq;
using System.Text;

using NUnit.Framework;

using Python.Runtime;

namespace Python.EmbeddingTest
{
    class TestPyIter
    {
        [OneTimeSetUp]
        public void SetUp()
        {
            PythonEngine.Initialize();
        }

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

        [Test]
        public void KeepOldObjects()
        {
            using (Py.GIL())
            using (var testString = new PyString("hello world! !$%&/()=?"))
            {
                PyObject[] chars = testString.ToArray();
                Assert.IsTrue(chars.Length > 1);
                string reconstructed = string.Concat(chars.Select(c => c.As()));
                Assert.AreEqual(testString.As(), reconstructed);
            }
        }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page