Skip to content

Commit df75164

Browse files
Add PyIter_Check and PyObject_IsIterable tests on threading.Lock, which does not have type feature iter
1 parent c538e9f commit df75164

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/tests/test_runtime.py

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88
import clr
99
import Python.Runtime
10+
import threading
1011

1112
def test_pyobject_isiterable_on_list():
1213
"""Tests that Runtime.PyObject_IsIterable is true for lists ."""
@@ -31,3 +32,19 @@ def test_pyiter_check_on_listiterator():
3132
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
3233
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyIter_Check", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
3334
assert m.Invoke(None, [ip]) == True
35+
36+
def test_pyiter_check_on_threadlock():
37+
"""Tests that Runtime.PyIter_Check is true for list iterators."""
38+
assy=clr.AddReference("Python.Runtime")
39+
x = threading.Lock()
40+
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
41+
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyIter_Check", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
42+
assert m.Invoke(None, [ip]) == False
43+
44+
def test_pyobject_isiterable_on_threadlock():
45+
"""Tests that Runtime.PyIter_Check is true for list iterators."""
46+
assy=clr.AddReference("Python.Runtime")
47+
x = threading.Lock()
48+
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
49+
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyObject_IsIterable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
50+
assert m.Invoke(None, [ip]) == False

0 commit comments

Comments
 (0)