Skip to content

Commit 1ca0bdb

Browse files
committed
fixed conversion tests to match new behavior
1 parent b13bafd commit 1ca0bdb

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

tests/test_array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99

1010
from collections import UserList
11+
from System import Single as float32
1112

1213

1314
def test_public_array():
@@ -533,8 +534,8 @@ def test_single_array():
533534
assert items[0] == 0.0
534535
assert items[4] == 4.0
535536

536-
max_ = 3.402823e38
537-
min_ = -3.402823e38
537+
max_ = float32(3.402823e38)
538+
min_ = float32(-3.402823e38)
538539

539540
items[0] = max_
540541
assert items[0] == max_
@@ -1291,7 +1292,7 @@ def test_special_array_creation():
12911292

12921293
value = Array[System.Single]([0.0, 3.402823e38])
12931294
assert value[0] == 0.0
1294-
assert value[1] == 3.402823e38
1295+
assert value[1] == System.Single(3.402823e38)
12951296
assert value.Length == 2
12961297

12971298
value = Array[System.Double]([0.0, 1.7976931348623157e308])

tests/test_conversion.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,10 @@ def test_single_conversion():
413413
assert ob.SingleField == 0.0
414414

415415
ob.SingleField = 3.402823e38
416-
assert ob.SingleField == 3.402823e38
416+
assert ob.SingleField == System.Single(3.402823e38)
417417

418418
ob.SingleField = -3.402823e38
419-
assert ob.SingleField == -3.402823e38
420-
421-
ob.SingleField = System.Single(3.402823e38)
422-
assert ob.SingleField == 3.402823e38
423-
424-
ob.SingleField = System.Single(-3.402823e38)
425-
assert ob.SingleField == -3.402823e38
419+
assert ob.SingleField == System.Single(-3.402823e38)
426420

427421
with pytest.raises(TypeError):
428422
ConversionTest().SingleField = "spam"

tests/test_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def test_single_field():
300300
assert ob.SingleField == 0.0
301301

302302
ob.SingleField = 1.1
303-
assert ob.SingleField == 1.1
303+
assert ob.SingleField == System.Single(1.1)
304304

305305

306306
def test_double_field():

tests/test_generic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_generic_type_binding():
259259
assert_generic_wrapper_by_type(System.UInt16, 65000)
260260
assert_generic_wrapper_by_type(System.UInt32, 4294967295)
261261
assert_generic_wrapper_by_type(System.UInt64, 18446744073709551615)
262-
assert_generic_wrapper_by_type(System.Single, 3.402823e38)
262+
assert_generic_wrapper_by_type(System.Single, System.Single(3.402823e38))
263263
assert_generic_wrapper_by_type(System.Double, 1.7976931348623157e308)
264264
assert_generic_wrapper_by_type(float, 1.7976931348623157e308)
265265
assert_generic_wrapper_by_type(System.Decimal, System.Decimal.One)
@@ -309,7 +309,7 @@ def test_generic_method_type_handling():
309309
assert_generic_method_by_type(System.Int32, 2147483647)
310310
assert_generic_method_by_type(int, 2147483647)
311311
assert_generic_method_by_type(System.UInt16, 65000)
312-
assert_generic_method_by_type(System.Single, 3.402823e38)
312+
assert_generic_method_by_type(System.Single, System.Single(3.402823e38))
313313
assert_generic_method_by_type(System.Double, 1.7976931348623157e308)
314314
assert_generic_method_by_type(float, 1.7976931348623157e308)
315315
assert_generic_method_by_type(System.Decimal, System.Decimal.One)
@@ -504,7 +504,7 @@ def test_method_overload_selection_with_generic_types():
504504
vtype = GenericWrapper[System.Single]
505505
input_ = vtype(3.402823e38)
506506
value = MethodTest.Overloaded.__overloads__[vtype](input_)
507-
assert value.value == 3.402823e38
507+
assert value.value == System.Single(3.402823e38)
508508

509509
vtype = GenericWrapper[System.Double]
510510
input_ = vtype(1.7976931348623157e308)
@@ -663,7 +663,7 @@ def test_overload_selection_with_arrays_of_generic_types():
663663
vtype = System.Array[gtype]
664664
input_ = vtype([gtype(3.402823e38), gtype(3.402823e38)])
665665
value = MethodTest.Overloaded.__overloads__[vtype](input_)
666-
assert value[0].value == 3.402823e38
666+
assert value[0].value == System.Single(3.402823e38)
667667
assert value.Length == 2
668668

669669
gtype = GenericWrapper[System.Double]

tests/test_method.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def test_explicit_overload_selection():
510510
assert value == 18446744073709551615
511511

512512
value = MethodTest.Overloaded.__overloads__[System.Single](3.402823e38)
513-
assert value == 3.402823e38
513+
assert value == System.Single(3.402823e38)
514514

515515
value = MethodTest.Overloaded.__overloads__[System.Double](
516516
1.7976931348623157e308)
@@ -645,7 +645,7 @@ def test_overload_selection_with_array_types():
645645
input_ = vtype([0.0, 3.402823e38])
646646
value = MethodTest.Overloaded.__overloads__[vtype](input_)
647647
assert value[0] == 0.0
648-
assert value[1] == 3.402823e38
648+
assert value[1] == System.Single(3.402823e38)
649649

650650
vtype = Array[System.Double]
651651
input_ = vtype([0.0, 1.7976931348623157e308])

tests/test_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def test_clr_get_clr_type():
357357
comparable = GetClrType(IComparable)
358358
assert comparable.FullName == "System.IComparable"
359359
assert comparable.IsInterface
360-
assert GetClrType(int).FullName == "System.Int32"
360+
assert GetClrType(int).FullName == "Python.Runtime.PyInt"
361361
assert GetClrType(str).FullName == "System.String"
362362
assert GetClrType(float).FullName == "System.Double"
363363
dblarr = System.Array[System.Double]

0 commit comments

Comments
 (0)