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
Prev Previous commit
Next Next commit
Revert "modified existing method out parameter tests"
This reverts commit 1964a49.
  • Loading branch information
eirannejad committed Jan 14, 2022
commit f07cbb980c5760bb18438788be23007e5bc4a9e3
28 changes: 24 additions & 4 deletions tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,13 @@ def test_params_method_with_lists():

def test_string_out_params():
"""Test use of string out-parameters."""
result = MethodTest.TestStringOutParams("hi")
result = MethodTest.TestStringOutParams("hi", "there")
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0] is True
assert result[1] == "output string"

result = MethodTest.TestStringOutParams("hi", None)
assert isinstance(result, tuple)
Comment thread
eirannejad marked this conversation as resolved.
assert len(result) == 2
assert result[0] is True
Expand All @@ -291,12 +297,16 @@ def test_string_ref_params():

def test_value_out_params():
"""Test use of value type out-parameters."""
result = MethodTest.TestValueOutParams("hi")
result = MethodTest.TestValueOutParams("hi", 1)
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0] is True
assert result[1] == 42

# None cannot be converted to a value type like int, long, etc.
with pytest.raises(TypeError):
MethodTest.TestValueOutParams("hi", None)


def test_value_ref_params():
"""Test use of value type byref parameters."""
Expand All @@ -313,7 +323,13 @@ def test_value_ref_params():

def test_object_out_params():
"""Test use of object out-parameters."""
result = MethodTest.TestObjectOutParams("hi")
result = MethodTest.TestObjectOutParams("hi", MethodTest())
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0] is True
assert isinstance(result[1], System.Exception)

result = MethodTest.TestObjectOutParams("hi", None)
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0] is True
Expand All @@ -337,12 +353,16 @@ def test_object_ref_params():

def test_struct_out_params():
"""Test use of struct out-parameters."""
result = MethodTest.TestStructOutParams("hi")
result = MethodTest.TestStructOutParams("hi", System.Guid.NewGuid())
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0] is True
assert isinstance(result[1], System.Guid)

# None cannot be converted to a value type like a struct
with pytest.raises(TypeError):
MethodTest.TestValueRefParams("hi", None)


def test_struct_ref_params():
"""Test use of struct byref parameters."""
Expand Down