File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """Test clrmethod and clrproperty support for calling methods and getting/setting python properties from CLR."""
4
+
5
+ import Python .Test as Test
6
+ import System
7
+ import pytest
8
+ import clr
9
+ import Python .Runtime
10
+
11
+ def test_pyobject_isiterable_on_list ():
12
+ """Tests that Runtime.PyObject_IsIterable is true for lists ."""
13
+ assy = clr .AddReference ("Python.Runtime" )
14
+ x = []
15
+ ip = System .IntPtr .op_Explicit (System .Int64 (id (x )))
16
+ m = assy .GetType ("Python.Runtime.Runtime" ).GetMethod ("PyObject_IsIterable" , System .Reflection .BindingFlags .NonPublic | System .Reflection .BindingFlags .Static )
17
+ assert m .Invoke (None , [ip ]) == True
18
+
19
+ def test_pyiter_check_on_list ():
20
+ """Tests that Runtime.PyIter_Check is false for lists."""
21
+ assy = clr .AddReference ("Python.Runtime" )
22
+ x = []
23
+ ip = System .IntPtr .op_Explicit (System .Int64 (id (x )))
24
+ m = assy .GetType ("Python.Runtime.Runtime" ).GetMethod ("PyIter_Check" , System .Reflection .BindingFlags .NonPublic | System .Reflection .BindingFlags .Static )
25
+ assert m .Invoke (None , [ip ]) == False
26
+
27
+ def test_pyiter_check_on_listiterator ():
28
+ """Tests that Runtime.PyIter_Check is true for list iterators."""
29
+ assy = clr .AddReference ("Python.Runtime" )
30
+ x = [].__iter__ ()
31
+ ip = System .IntPtr .op_Explicit (System .Int64 (id (x )))
32
+ m = assy .GetType ("Python.Runtime.Runtime" ).GetMethod ("PyIter_Check" , System .Reflection .BindingFlags .NonPublic | System .Reflection .BindingFlags .Static )
33
+ assert m .Invoke (None , [ip ]) == True
You can’t perform that action at this time.
0 commit comments