Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Next Next commit
Add tests of subclassing with __namespace__
  • Loading branch information
Rickard Holmberg committed Jun 20, 2017
commit 5f9a108b86ac06dc2ed58fa6e702f0b3bd281e61
29 changes: 29 additions & 0 deletions src/tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,32 @@ def test_isinstance_check():
for x in b:
assert isinstance(x, System.Object)
assert isinstance(x, System.String)

def test_clr_subclass_with_init_args():
calls = []
class TestX(System.Object):
__namespace__ = "test_clr_subclass_with_init_args"
def __init__(self, *args, **kwargs):
calls.append((args, kwargs))
t = TestX(1,2,3,foo="bar")
assert len(calls) == 1
assert calls[0][0] == (1,2,3)
assert calls[0][1] == {"foo":"bar"}

def test_clr_subclass_without_init_args():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename test_clr_subclass_init_without_args

calls = []
class TestX(System.Object):
__namespace__ = "test_clr_subclass_without_init_args"
def __init__(self):
calls.append(True)
t = TestX()
assert len(calls) == 1
assert calls[0] == True


def test_clr_subclass_without_init():
class TestX(System.Object):
__namespace__ = "test_clr_subclass_without_init"
q = 1
t = TestX()
assert t.q == 1