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

Commitb3bbdfb

Browse files
committed
Merge pull request#341 from filmor/improve-tests
2 parentsf4d83cf +689c1fc commitb3bbdfb

File tree

5 files changed

+41
-46
lines changed

5 files changed

+41
-46
lines changed

‎src/embed_tests/InitializeTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
usingNUnit.Framework;
2+
usingPython.Runtime;
3+
usingSystem;
4+
usingSystem.Collections.Generic;
5+
usingSystem.Linq;
6+
usingSystem.Text;
7+
8+
namespacePython.EmbeddingTest
9+
{
10+
publicclassInitializeTest
11+
{
12+
[Test]
13+
publicstaticvoidTest()
14+
{
15+
PythonEngine.Initialize();
16+
PythonEngine.Shutdown();
17+
18+
PythonEngine.Initialize();
19+
PythonEngine.Shutdown();
20+
}
21+
}
22+
}

‎src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,23 @@
128128
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
129129
</PropertyGroup>
130130
<ItemGroup>
131+
<ReferenceInclude="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
132+
<HintPath>..\..\packages\NUnit.3.5.0\lib\net40\nunit.framework.dll</HintPath>
133+
<Private>True</Private>
134+
</Reference>
131135
<ReferenceInclude="System" />
132136
<ReferenceInclude="System.Core">
133137
<RequiredTargetFramework>3.5</RequiredTargetFramework>
134138
</Reference>
135-
<ReferenceInclude="nunit.framework">
136-
<HintPath>..\..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
137-
</Reference>
138139
</ItemGroup>
139140
<ItemGroup>
140141
<NoneInclude="Embeddingtest.nunit" />
141142
<NoneInclude="..\pythonnet.snk" />
142143
<NoneInclude="packages.config" />
144+
<NoneInclude="pythonnet.snk"Condition="Exists('pythonnet.snk')" />
143145
</ItemGroup>
144146
<ItemGroup>
147+
<CompileInclude="InitializeTest.cs" />
145148
<CompileInclude="pyimport.cs" />
146149
<CompileInclude="pyiter.cs">
147150
<SubType>Code</SubType>
@@ -172,6 +175,9 @@
172175
<Name>Python.Runtime</Name>
173176
</ProjectReference>
174177
</ItemGroup>
178+
<ItemGroup>
179+
<ServiceInclude="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
180+
</ItemGroup>
175181
<ImportProject="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
176182
<ProjectExtensions>
177183
<VisualStudioAllowExistingFolder="true" />

‎src/embed_tests/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
32
<packages>
4-
<packageid="NUnit"version="2.6.2"targetFramework="net40" />
3+
<packageid="NUnit"version="3.5.0"targetFramework="net40" />
54
</packages>

‎src/embed_tests/pyimport.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
usingSystem.Collections.Generic;
44
usingNUnit.Framework;
55
usingPython.Runtime;
6+
usingSystem.IO;
67

78
namespacePython.EmbeddingTest
89
{
@@ -17,34 +18,19 @@ public void SetUp()
1718
PythonEngine.Initialize();
1819
gs=PythonEngine.AcquireLock();
1920

20-
//string here = Environment.CurrentDirectory;
21-
//trunk\pythonnet\src\embed_tests\bin\x86\DebugWin
22-
2321
/*
2422
* Append the tests directory to sys.path
2523
* using reflection to circumvent the private modifires placed on most Runtime methods.
2624
*/
2725
conststrings=@"../../../../tests";
2826

29-
TypeRTClass=typeof(Runtime.Runtime);
30-
31-
/* pyStrPtr = PyString_FromString(s); */
32-
MethodInfoPyString_FromString=RTClass.GetMethod("PyString_FromString",
33-
BindingFlags.NonPublic|BindingFlags.Static);
34-
object[]funcArgs=newobject[1];
35-
funcArgs[0]=s;
36-
IntPtrpyStrPtr=(IntPtr)PyString_FromString.Invoke(null,funcArgs);
37-
38-
/* SysDotPath = sys.path */
39-
MethodInfoPySys_GetObject=RTClass.GetMethod("PySys_GetObject",
40-
BindingFlags.NonPublic|BindingFlags.Static);
41-
funcArgs[0]="path";
42-
IntPtrSysDotPath=(IntPtr)PySys_GetObject.Invoke(null,funcArgs);
27+
vartestPath=Path.Combine(
28+
TestContext.CurrentContext.TestDirectory,s
29+
);
4330

44-
/* SysDotPath.append(*pyStrPtr) */
45-
MethodInfoPyList_Append=RTClass.GetMethod("PyList_Append",BindingFlags.NonPublic|BindingFlags.Static);
46-
funcArgs=newobject[]{SysDotPath,pyStrPtr};
47-
intr=(int)PyList_Append.Invoke(null,funcArgs);
31+
IntPtrstr=Runtime.Runtime.PyString_FromString(testPath);
32+
IntPtrpath=Runtime.Runtime.PySys_GetObject("path");
33+
Runtime.Runtime.PyList_Append(path,str);
4834
}
4935

5036
[TearDown]

‎src/runtime/assemblyinfo.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
usingSystem.Reflection;
33
usingSystem.Resources;
44
usingSystem.Runtime.InteropServices;
5+
usingSystem.Runtime.CompilerServices;
56

67
[assembly:AssemblyProduct("Python for .NET")]
78
[assembly:AssemblyVersion("4.0.0.1")]
@@ -11,23 +12,4 @@
1112
[assembly:AssemblyCopyright("MIT License")]
1213
[assembly:AssemblyFileVersion("2.0.0.2")]
1314
[assembly:NeutralResourcesLanguage("en")]
14-
15-
#ifPYTHON27
16-
[assembly:AssemblyTitle("Python.Runtime for Python 2.7")]
17-
[assembly:AssemblyDescription("Python Runtime for Python 2.7")]
18-
#elifPYTHON33
19-
[assembly:AssemblyTitle("Python.Runtime for Python 3.3")]
20-
[assembly:AssemblyDescription("Python Runtime for Python 3.3")]
21-
#elifPYTHON34
22-
[assembly:AssemblyTitle("Python.Runtime for Python 3.4")]
23-
[assembly:AssemblyDescription("Python Runtime for Python 3.4")]
24-
#elifPYTHON35
25-
[assembly:AssemblyTitle("Python.Runtime for Python 3.5")]
26-
[assembly:AssemblyDescription("Python Runtime for Python 3.5")]
27-
#elifPYTHON36
28-
[assembly:AssemblyTitle("Python.Runtime for Python 3.6")]
29-
[assembly:AssemblyDescription("Python Runtime for Python 3.6")]
30-
#elifPYTHON37
31-
[assembly:AssemblyTitle("Python.Runtime for Python 3.7")]
32-
[assembly:AssemblyDescription("Python Runtime for Python 3.7")]
33-
#endif
15+
[assembly:InternalsVisibleTo("Python.EmbeddingTest")]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp