8000 clrmethod working for python 2 by rickardraysearch · Pull Request #494 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

clrmethod working for python 2 #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 16, 2017
Prev Previous commit
Next Next commit
Add PyIter_Check and PyObject_IsIterable tests on threading.Lock, whi…
…ch does not have type feature iter
  • Loading branch information
rickardraysearch committed Jun 15, 2017
commit 1a85eef6465b635deb9a5dfee9aeb4bc4be6bc62
17 changes: 17 additions & 0 deletions src/tests/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import clr
import Python.Runtime
import threading

def test_pyobject_isiterable_on_list():
"""Tests that Runtime.PyObject_IsIterable is true for lists ."""
Expand All @@ -31,3 +32,19 @@ def test_pyiter_check_on_listiterator():
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyIter_Check", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
assert m.Invoke(None, [ip]) == True

def test_pyiter_check_on_threadlock():
"""Tests that Runtime.PyIter_Check is false for threading.Lock, which uses a different code path in PyIter_Check."""
assy=clr.AddReference("Python.Runtime")
x = threading.Lock()
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyIter_Check", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
assert m.Invoke(None, [ip]) == False

def test_pyobject_isiterable_on_threadlock():
"""Tests that Runtime.PyObject_IsIterable is false for threading.Lock, which uses a different code path in PyObject_IsIterable."""
assy=clr.AddReference("Python.Runtime")
x = threading.Lock()
ip = System.IntPtr.op_Explicit(System.Int64(id(x)))
m=assy.GetType("Python.Runtime.Runtime").GetMethod("PyObject_IsIterable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)
assert m.Invoke(None, [ip]) == False
0