11using NUnit . Framework ;
22using Python . Runtime ;
3- using System ;
4- using System . Collections . Generic ;
5- using System . Linq ;
6- using System . Text ;
73
84namespace Python . EmbeddingTest
95{
@@ -28,49 +24,49 @@ public void TearDown()
2824 [ Test ]
2925 public void Eval ( )
3026 {
31- using ( var ps = Py . Session ( ) )
27+ using ( PySession ps = Py . Session ( ) )
3228 {
33- var result = PyInt . AsInt ( ps . Eval ( "1+2" ) ) ;
29+ PyInt result = PyInt . AsInt ( ps . Eval ( "1+2" ) ) ;
3430 Assert . AreEqual ( result . ToInt32 ( ) , 3 ) ;
3531 }
3632 }
3733
3834 [ Test ]
3935 public void Exec ( )
4036 {
41- using ( var ps = Py . Session ( ) )
37+ using ( PySession ps = Py . Session ( ) )
4238 {
43- ps . SetGlobal ( "bb" , 100 ) ; //declare a global variable
44- ps . SetLocal ( "cc" , 10 ) ; //declare a local variable
39+ ps . SetGlobal ( "bb" , 100 ) ; //declare a global variable
40+ ps . SetLocal ( "cc" , 10 ) ; //declare a local variable
4541 ps . ExecIn ( "aa=bb+cc+3" ) ;
46- var result = PyInt . AsInt ( ps . Get ( "aa" ) as PyObject ) ;
42+ PyInt result = PyInt . AsInt ( ps . Get ( "aa" ) as PyObject ) ;
4743 Assert . AreEqual ( result . ToInt32 ( ) , 113 ) ;
4844 }
4945 }
5046
5147 [ Test ]
5248 public void ExecIn ( )
5349 {
54- using ( var ps = Py . Session ( ) )
50+ using ( PySession ps = Py . Session ( ) )
5551 {
56- ps . SetGlobal ( "bb" , 100 ) ; //declare a global variable
57- ps . SetLocal ( "cc" , 10 ) ; //declare a local variable
52+ ps . SetGlobal ( "bb" , 100 ) ; //declare a global variable
53+ ps . SetLocal ( "cc" , 10 ) ; //declare a local variable
5854 ps . ExecIn ( "aa=bb+cc+3" ) ;
59- var result = PyInt . AsInt ( ps . Get ( "aa" ) as PyObject ) ;
55+ PyInt result = PyInt . AsInt ( ps . Get ( "aa" ) as PyObject ) ;
6056 Assert . AreEqual ( result . ToInt32 ( ) , 113 ) ;
6157 }
6258 }
6359
6460 [ Test ]
6561 public void Import ( )
6662 {
67- using ( var ps = Py . Session ( ) )
63+ using ( PySession ps = Py . Session ( ) )
6864 {
69- ps . Import ( "sys" ) ; //import, it will also be added in globals
65+ ps . Import ( "sys" ) ; //import, it will also be added in globals
7066 ps . Import ( "io" ) ;
71- ps . ExecIn ( "sys.stdout = io.StringIO()" ) ; //it's working!
67+ ps . ExecIn ( "sys.stdout = io.StringIO()" ) ; //it's working!
7268 ps . ExecIn ( "print('Hello!')" ) ;
73- var result = ps . Eval ( "sys.stdout.getvalue()" ) ;
69+ PyObject result = ps . Eval ( "sys.stdout.getvalue()" ) ;
7470 Assert . AreEqual ( result . ToString ( ) , "Hello!\n " ) ;
7571 }
7672 }
0 commit comments