forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyiter.cs
More file actions
43 lines (39 loc) · 1.06 KB
/
pyiter.cs
File metadata and controls
43 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Python.Runtime;
namespace Python.EmbeddingTest
{
[TestFixture]
public class PyIterTest
{
private IntPtr gs;
[SetUp]
public void SetUp()
{
PythonEngine.Initialize();
gs = PythonEngine.AcquireLock();
}
[TearDown]
public void TearDown()
{
PythonEngine.ReleaseLock(gs);
PythonEngine.Shutdown();
}
[Test]
public void TestOnPyList()
{
PyList list = new PyList();
list.Append(new PyString("foo"));
list.Append(new PyString("bar"));
list.Append(new PyString("baz"));
List<string> result = new List<string>();
foreach (PyObject item in list)
result.Add(item.ToString());
Assert.AreEqual(3, result.Count);
Assert.AreEqual("foo",result[0]);
Assert.AreEqual("bar",result[1]);
Assert.AreEqual("baz",result[2]);
}
}
}