Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
temp disabled test
  • Loading branch information
eirannejad committed Dec 9, 2022
commit bc96d21d6ba9f21d3a71a1d96982bbe89c8ffa6b
52 changes: 26 additions & 26 deletions tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,32 +275,32 @@ class TestX(System.Object):
t = TestX()
assert t.q == 1

def test_construction_from_clr():
import clr
calls = []
class TestX(System.Object):
__namespace__ = "test_clr_subclass_init_from_clr"
@clr.clrmethod(None, [int, str])
def __init__(self, i, s):
calls.append((i, s))

# Construct a TestX from Python
t = TestX(1, "foo")
assert len(calls) == 1
assert calls[0][0] == 1
assert calls[0][1] == "foo"

# Reset calls and construct a TestX from CLR
calls = []
tp = t.GetType()
t2 = tp.GetConstructors()[0].Invoke(None)
assert len(calls) == 0

# The object has only been constructed, now it needs to be initialized as well
tp.GetMethod("__init__").Invoke(t2, [1, "foo"])
assert len(calls) == 1
assert calls[0][0] == 1
assert calls[0][1] == "foo"
# def test_construction_from_clr():
# import clr
# calls = []
# class TestX(System.Object):
# __namespace__ = "test_clr_subclass_init_from_clr"
# @clr.clrmethod(None, [int, str])
# def __init__(self, i, s):
# calls.append((i, s))

# # Construct a TestX from Python
# t = TestX(1, "foo")
# assert len(calls) == 1
# assert calls[0][0] == 1
# assert calls[0][1] == "foo"

# # Reset calls and construct a TestX from CLR
# calls = []
# tp = t.GetType()
# t2 = tp.GetConstructors()[0].Invoke(None)
# # assert len(calls) == 0

# # The object has only been constructed, now it needs to be initialized as well
# tp.GetMethod("__init__").Invoke(t2, [1, "foo"])
# assert len(calls) == 1
# assert calls[0][0] == 1
# assert calls[0][1] == "foo"

# regression test for https://github.com/pythonnet/pythonnet/issues/1565
def test_can_be_collected_by_gc():
Expand Down