@@ -81,7 +81,7 @@ public void SetUp()
8181 catch ( PythonException )
8282 {
8383 }
84- module = PythonEngine . ModuleFromString ( "module" , testModule ) . GetAttr ( "PythonModel" ) . Invoke ( ) ;
84+ module = PyModule . FromString ( "module" , testModule ) . GetAttr ( "PythonModel" ) . Invoke ( ) ;
8585 }
8686
8787 [ OneTimeTearDown ]
@@ -152,7 +152,7 @@ public void ImplicitConversionErrorHandling()
152152 catch ( Exception e )
153153 {
154154 errorCaught = true ;
155- Assert . AreEqual ( "TypeError : Failed to implicitly convert Python.EmbeddingTest.TestMethodBinder+ErroredImplicitConversion to System.String" , e . Message ) ;
155+ Assert . AreEqual ( "Failed to implicitly convert Python.EmbeddingTest.TestMethodBinder+ErroredImplicitConversion to System.String" , e . Message ) ;
156156 }
157157
158158 Assert . IsTrue ( errorCaught ) ;
@@ -243,7 +243,7 @@ public void NumpyDateTime64()
243243 var numpyDateTime = Numpy . datetime64 ( "2011-02" ) ;
244244
245245 object result ;
246- var converted = Converter . ToManaged ( numpyDateTime . Handle , typeof ( DateTime ) , out result , false ) ;
246+ var converted = Converter . ToManaged ( numpyDateTime , typeof ( DateTime ) , out result , false ) ;
247247
248248 Assert . IsTrue ( converted ) ;
249249 Assert . AreEqual ( new DateTime ( 2011 , 02 , 1 ) , result ) ;
@@ -312,7 +312,7 @@ public void TestNonStaticGenericMethodBinding()
312312 Assert . AreEqual ( 1 , class2 . Value ) ;
313313
314314 // Run in Python
315- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
315+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
316316from clr import AddReference
317317AddReference(""System"")
318318AddReference(""Python.EmbeddingTest"")
@@ -345,7 +345,7 @@ public void TestGenericMethodBinding()
345345 Assert . AreEqual ( 1 , class2 . Value ) ;
346346
347347 // Run in Python
348- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
348+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
349349from clr import AddReference
350350AddReference(""System"")
351351AddReference(""Python.EmbeddingTest"")
@@ -378,7 +378,7 @@ public void TestMultipleGenericMethodBinding()
378378 Assert . AreEqual ( 1 , class2 . Value ) ;
379379
380380 // Run in Python
381- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
381+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
382382from clr import AddReference
383383AddReference(""System"")
384384AddReference(""Python.EmbeddingTest"")
@@ -419,7 +419,7 @@ public void TestMultipleGenericParamMethodBinding()
419419 Assert . AreEqual ( 1 , class2b . Value ) ;
420420
421421 // Run in Python
422- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
422+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
423423from clr import AddReference
424424AddReference(""System"")
425425AddReference(""Python.EmbeddingTest"")
@@ -466,7 +466,7 @@ public void TestMultipleGenericParamMethodBinding_MixedOrder()
466466 Assert . AreEqual ( 1 , class2b . Value ) ;
467467
468468 // Run in Python
469- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
469+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
470470from clr import AddReference
471471AddReference(""System"")
472472AddReference(""Python.EmbeddingTest"")
@@ -493,7 +493,7 @@ raise AssertionError('Values were not updated')
493493 public void TestPyClassGenericBinding ( )
494494 {
495495 // Overriding our generics in Python we should still match with the generic method
496- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
496+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
497497from clr import AddReference
498498AddReference(""System"")
499499AddReference(""Python.EmbeddingTest"")
@@ -527,7 +527,7 @@ public void TestNonGenericIsUsedWhenAvailable()
527527
528528
529529 // When available, should select non-generic method over generic method
530- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
530+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
531531from clr import AddReference
532532AddReference(""System"")
533533AddReference(""Python.EmbeddingTest"")
@@ -551,7 +551,7 @@ public void TestMatchTypedGenericOverload()
551551 TestGenericMethod ( class1 ) ;
552552 Assert . AreEqual ( 15 , class1 . Value ) ;
553553
554- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
554+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
555555from clr import AddReference
556556AddReference(""System"")
557557AddReference(""Python.EmbeddingTest"")
@@ -586,7 +586,7 @@ public void TestGenericTypeMatchingWithConvertedPyType()
586586 // This test ensures that we can still match and bind a generic method when we
587587 // have a converted pytype in the args (py timedelta -> C# TimeSpan)
588588
589- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
589+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
590590from datetime import timedelta
591591from clr import AddReference
592592AddReference(""System"")
@@ -608,7 +608,7 @@ public void TestGenericTypeMatchingWithDefaultArgs()
608608 {
609609 // This test ensures that we can still match and bind a generic method when we have default args
610610
611- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
611+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
612612from datetime import timedelta
613613from clr import AddReference
614614AddReference(""System"")
@@ -628,13 +628,13 @@ raise AssertionError('Value was not 50, was {class1.Value}')
628628" ) ) ;
629629 }
630630
631- [ Test ]
631+ [ Test ]
632632 public void TestGenericTypeMatchingWithNullDefaultArgs ( )
633633 {
634634 // This test ensures that we can still match and bind a generic method when we have \
635635 // null default args, important because caching by arg types occurs
636636
637- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
637+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
638638from datetime import timedelta
639639from clr import AddReference
640640AddReference(""System"")
@@ -658,7 +658,7 @@ raise AssertionError('Value was not 50, was {class1.Value}')
658658 public void TestMatchPyDateToDateTime ( )
659659 {
660660 // This test ensures that we match py datetime.date object to C# DateTime object
661- Assert . DoesNotThrow ( ( ) => PythonEngine . ModuleFromString ( "test" , @"
661+ Assert . DoesNotThrow ( ( ) => PyModule . FromString ( "test" , @"
662662from datetime import *
663663from clr import AddReference
664664AddReference(""System"")
@@ -675,7 +675,8 @@ from Python.EmbeddingTest import *
675675
676676
677677 // Used to test that we match this function with Py DateTime & Date Objects
678- public static int GetMonth ( DateTime test ) {
678+ public static int GetMonth ( DateTime test )
679+ {
679680 return test . Month ;
680681 }
681682
@@ -875,7 +876,8 @@ public static void TestGenericMethodWithDefault<T>(GenericClassBase<T> test, int
875876 public static void TestGenericMethodWithNullDefault < T > ( GenericClassBase < T > test , Object testObj = null )
876877 where T : class
877878 {
878- if ( testObj == null ) {
879+ if ( testObj == null )
880+ {
879881 test . Value = 10 ;
880882 }
881883 else
0 commit comments