Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Some fixes.#219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 6 commits intopythonnet:masterfrommatthid:myfixes
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from1 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
PrevPrevious commit
NextNext commit
add test for using null like 'None' for default arguments. See35cd5fa
  • Loading branch information
@matthid
matthid committedJun 23, 2016
commit65626c3c5f8e82e7b51cccf92a86d51eb0dab444
2 changes: 2 additions & 0 deletionssrc/testing/Python.Test.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -108,6 +108,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="arraytest.cs" />
<Compile Include="callbacktest.cs" />
<Compile Include="classtest.cs" />
<Compile Include="constructortests.cs" />
<Compile Include="conversiontest.cs" />
Expand All@@ -127,6 +128,7 @@
<Compile Include="subclasstest.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
Expand Down
31 changes: 31 additions & 0 deletionssrc/testing/callbacktest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Python.Test
{
//========================================================================
// Tests callbacks into python code.
//========================================================================

public class CallbackTest
{
public string Call_simpleDefaultArg_WithNull(string moduleName)
{
using (Runtime.Py.GIL())
{
dynamic module = Runtime.Py.Import(moduleName);
return module.simpleDefaultArg(null);
}
}
public string Call_simpleDefaultArg_WithEmptyArgs(string moduleName)
{
using (Runtime.Py.GIL())
{
dynamic module = Runtime.Py.Import(moduleName);
return module.simpleDefaultArg();
}
}
}
}
2 changes: 2 additions & 0 deletionssrc/tests/test_suite/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,10 @@
__all__ = ['test_suite']

from .test_import import test_suite as import_tests
from .test_callback import test_suite as callback_tests

def test_suite():
suite = unittest.TestSuite()
suite.addTests((import_tests(),))
suite.addTests((callback_tests(),))
return suite
30 changes: 30 additions & 0 deletionssrc/tests/test_suite/test_callback.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
import unittest, sys
import clr

this_module = sys.modules[__name__]
clr.AddReference("Python.Test")
import Python.Test as Test
from Python.Test import CallbackTest
test_instance = CallbackTest()

def simpleDefaultArg(arg = 'test'):
return arg

class CallbackTests(unittest.TestCase):
"""Test that callbacks from C# into python work."""

def testDefaultForNull(self):
"""Test that C# can use null for an optional python argument"""
retVal = test_instance.Call_simpleDefaultArg_WithNull(__name__)
pythonRetVal = simpleDefaultArg(None)
self.assertEquals(retVal, pythonRetVal)

def testDefaultForNone(self):
"""Test that C# can use no argument for an optional python argument"""
retVal = test_instance.Call_simpleDefaultArg_WithEmptyArgs(__name__)
pythonRetVal = simpleDefaultArg()
self.assertEquals(retVal, pythonRetVal)

def test_suite():
return unittest.makeSuite(CallbackTests)


[8]ページ先頭

©2009-2025 Movatter.jp