Skip to content
Merged
Show file tree
Hide file tree
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
fixed conversion tests to match new behavior
  • Loading branch information
lostmsu committed Sep 27, 2021
commit b2e6d4ed4a5500e92d79749130b78fd2a15c0dc9
7 changes: 4 additions & 3 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

from collections import UserList
from System import Single as float32


def test_public_array():
Expand Down Expand Up @@ -533,8 +534,8 @@ def test_single_array():
assert items[0] == 0.0
assert items[4] == 4.0

max_ = 3.402823e38
min_ = -3.402823e38
max_ = float32(3.402823e38)
min_ = float32(-3.402823e38)

items[0] = max_
assert items[0] == max_
Expand Down Expand Up @@ -1291,7 +1292,7 @@ def test_special_array_creation():

value = Array[System.Single]([0.0, 3.402823e38])
assert value[0] == 0.0
assert value[1] == 3.402823e38
assert value[1] == System.Single(3.402823e38)
assert value.Length == 2

value = Array[System.Double]([0.0, 1.7976931348623157e308])
Expand Down
10 changes: 2 additions & 8 deletions tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,10 @@ def test_single_conversion():
assert ob.SingleField == 0.0

ob.SingleField = 3.402823e38
assert ob.SingleField == 3.402823e38
assert ob.SingleField == System.Single(3.402823e38)
Comment thread
filmor marked this conversation as resolved.

ob.SingleField = -3.402823e38
assert ob.SingleField == -3.402823e38

ob.SingleField = System.Single(3.402823e38)
assert ob.SingleField == 3.402823e38

ob.SingleField = System.Single(-3.402823e38)
assert ob.SingleField == -3.402823e38
assert ob.SingleField == System.Single(-3.402823e38)

with pytest.raises(TypeError):
ConversionTest().SingleField = "spam"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_single_field():
assert ob.SingleField == 0.0

ob.SingleField = 1.1
assert ob.SingleField == 1.1
assert ob.SingleField == System.Single(1.1)


def test_double_field():
Expand Down
8 changes: 4 additions & 4 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def test_generic_type_binding():
assert_generic_wrapper_by_type(System.UInt16, 65000)
assert_generic_wrapper_by_type(System.UInt32, 4294967295)
assert_generic_wrapper_by_type(System.UInt64, 18446744073709551615)
assert_generic_wrapper_by_type(System.Single, 3.402823e38)
assert_generic_wrapper_by_type(System.Single, System.Single(3.402823e38))
assert_generic_wrapper_by_type(System.Double, 1.7976931348623157e308)
assert_generic_wrapper_by_type(float, 1.7976931348623157e308)
assert_generic_wrapper_by_type(System.Decimal, System.Decimal.One)
Expand Down Expand Up @@ -309,7 +309,7 @@ def test_generic_method_type_handling():
assert_generic_method_by_type(System.Int32, 2147483647)
assert_generic_method_by_type(int, 2147483647)
assert_generic_method_by_type(System.UInt16, 65000)
assert_generic_method_by_type(System.Single, 3.402823e38)
assert_generic_method_by_type(System.Single, System.Single(3.402823e38))
assert_generic_method_by_type(System.Double, 1.7976931348623157e308)
assert_generic_method_by_type(float, 1.7976931348623157e308)
assert_generic_method_by_type(System.Decimal, System.Decimal.One)
Expand Down Expand Up @@ -504,7 +504,7 @@ def test_method_overload_selection_with_generic_types():
vtype = GenericWrapper[System.Single]
input_ = vtype(3.402823e38)
value = MethodTest.Overloaded.__overloads__[vtype](input_)
assert value.value == 3.402823e38
assert value.value == System.Single(3.402823e38)

vtype = GenericWrapper[System.Double]
input_ = vtype(1.7976931348623157e308)
Expand Down Expand Up @@ -663,7 +663,7 @@ def test_overload_selection_with_arrays_of_generic_types():
vtype = System.Array[gtype]
input_ = vtype([gtype(3.402823e38), gtype(3.402823e38)])
value = MethodTest.Overloaded.__overloads__[vtype](input_)
assert value[0].value == 3.402823e38
assert value[0].value == System.Single(3.402823e38)
assert value.Length == 2

gtype = GenericWrapper[System.Double]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_explicit_overload_selection():
assert value == 18446744073709551615

value = MethodTest.Overloaded.__overloads__[System.Single](3.402823e38)
assert value == 3.402823e38
assert value == System.Single(3.402823e38)

value = MethodTest.Overloaded.__overloads__[System.Double](
1.7976931348623157e308)
Expand Down Expand Up @@ -645,7 +645,7 @@ def test_overload_selection_with_array_types():
input_ = vtype([0.0, 3.402823e38])
value = MethodTest.Overloaded.__overloads__[vtype](input_)
assert value[0] == 0.0
assert value[1] == 3.402823e38
assert value[1] == System.Single(3.402823e38)

vtype = Array[System.Double]
input_ = vtype([0.0, 1.7976931348623157e308])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def test_clr_get_clr_type():
comparable = GetClrType(IComparable)
assert comparable.FullName == "System.IComparable"
assert comparable.IsInterface
assert GetClrType(int).FullName == "System.Int32"
assert GetClrType(int).FullName == "Python.Runtime.PyInt"
assert GetClrType(str).FullName == "System.String"
assert GetClrType(float).FullName == "System.Double"
dblarr = System.Array[System.Double]
Expand Down