File tree 4 files changed +65
-0
lines changed
4 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 108
108
</PropertyGroup >
109
109
<ItemGroup >
110
110
<Compile Include =" arraytest.cs" />
111
+ <Compile Include =" callbacktest.cs" />
111
112
<Compile Include =" classtest.cs" />
112
113
<Compile Include =" constructortests.cs" />
113
114
<Compile Include =" conversiontest.cs" />
127
128
<Compile Include =" subclasstest.cs" />
128
129
</ItemGroup >
129
130
<ItemGroup >
131
+ <Reference Include =" Microsoft.CSharp" />
130
132
<Reference Include =" System" />
131
133
<Reference Include =" System.Core" >
132
134
<RequiredTargetFramework >3.5</RequiredTargetFramework >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+
6
+ namespace Python . Test
7
+ {
8
+ //========================================================================
9
+ // Tests callbacks into python code.
10
+ //========================================================================
11
+
12
+ public class CallbackTest
13
+ {
14
+ public string Call_simpleDefaultArg_WithNull ( string moduleName )
15
+ {
16
+ using ( Runtime . Py . GIL ( ) )
17
+ {
18
+ dynamic module = Runtime . Py . Import ( moduleName ) ;
19
+ return module . simpleDefaultArg ( null ) ;
20
+ }
21
+ }
22
+ public string Call_simpleDefaultArg_WithEmptyArgs ( string moduleName )
23
+ {
24
+ using ( Runtime . Py . GIL ( ) )
25
+ {
26
+ dynamic module = Runtime . Py . Import ( moduleName ) ;
27
+ return module . simpleDefaultArg ( ) ;
28
+ }
29
+ }
30
+ }
31
+ }
Original file line number Diff line number Diff line change 3
3
__all__ = ['test_suite' ]
4
4
5
5
from .test_import import test_suite as import_tests
6
+ from .test_callback import test_suite as callback_tests
6
7
7
8
def test_suite ():
8
9
suite = unittest .TestSuite ()
9
10
suite .addTests ((import_tests (),))
11
+ suite .addTests ((callback_tests (),))
10
12
return suite
Original file line number Diff line number Diff line change
1
+ import unittest , sys
2
+ import clr
3
+
4
+ this_module = sys .modules [__name__ ]
5
+ clr .AddReference ("Python.Test" )
6
+ import Python .Test as Test
7
+ from Python .Test import CallbackTest
8
+ test_instance = CallbackTest ()
9
+
10
+ def simpleDefaultArg (arg = 'test' ):
11
+ return arg
12
+
13
+ class CallbackTests (unittest .TestCase ):
14
+ """Test that callbacks from C# into python work."""
15
+
16
+ def testDefaultForNull (self ):
17
+ """Test that C# can use null for an optional python argument"""
18
+ retVal = test_instance .Call_simpleDefaultArg_WithNull (__name__ )
19
+ pythonRetVal = simpleDefaultArg (None )
20
+ self .assertEquals (retVal , pythonRetVal )
21
+
22
+ def testDefaultForNone (self ):
23
+ """Test that C# can use no argument for an optional python argument"""
24
+ retVal = test_instance .Call_simpleDefaultArg_WithEmptyArgs (__name__ )
25
+ pythonRetVal = simpleDefaultArg ()
26
+ self .assertEquals (retVal , pythonRetVal )
27
+
28
+ def test_suite ():
29
+ return unittest .makeSuite (CallbackTests )
30
+
You can’t perform that action at this time.
0 commit comments