forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyiter.cs
More file actions
30 lines (29 loc) · 858 Bytes
/
pyiter.cs
File metadata and controls
30 lines (29 loc) · 858 Bytes
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
using System.Collections.Generic;
using NUnit.Framework;
using Python.Runtime;
namespace Python.EmbeddingTest
{
public class PyIterTest
{
[Test]
public void TestOnPyList()
{
using (Py.GIL())
{
var list = new PyList();
list.Append(new PyString("foo"));
list.Append(new PyString("bar"));
list.Append(new PyString("baz"));
var 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]);
}
}
}
}