8000 Small fixes for python tests under netcore 2.0. Improvements to tests… · HasmikM/pythonnet@f018085 · GitHub
[go: up one dir, main page]

Skip to content

Commit f018085

Browse files
author
dse
committed
Small fixes for python tests under netcore 2.0. Improvements to tests pack for .netcore 2.0.
1 parent aaa5f22 commit f018085

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/console/Console.15.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
<ItemGroup>
8686
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
8787
</ItemGroup>
88+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
89+
<PackageReference Include="System.Drawing.Primitives">
90+
<Version>4.3.0</Version>
91+
</PackageReference>
92+
</ItemGroup>
8893

8994
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
9095

src/console/pythonconsole.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ public static int Main(string[] args)
323 8000 2
AssemblyLoader a = assemblyLoader;
3333
#endif
3434
string[] cmd = Environment.GetCommandLineArgs();
35+
#if NETCOREAPP2_0
36+
// Forcing Runtime.Extension assembly to load.
37+
var tstType = typeof(System.Collections.Hashtable);
38+
if (!tstType.Assembly.FullName.StartsWith("System.Runtime.Extensions"))
39+
{
40+
Console.WriteLine("Hardcoded expectations on System.Runtime.Extensions library was not satisfied.");
41+
return 1;
42+
}
43+
#endif
3544
PythonEngine.Initialize();
3645

3746
int i = Runtime.Py_Main(cmd.Length, cmd);

src/runtime/nativecall.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ internal class NativeCall
2727
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
2828
private delegate void Void_1_Delegate(IntPtr a1);
2929

30-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
31-
private delegate int Int_3_Delegate(IntPtr a1, IntPtr a2, IntPtr a3);
32-
3330
public static void Void_Call_1(IntPtr fp, IntPtr a1)
3431
{
3532
((Void_1_Delegate)Marshal.GetDelegateForFunctionPointer(fp, typeof(Void_1_Delegate)))(a1);
@@ -44,7 +41,7 @@ public static IntPtr Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3)
4441

4542
public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3)
4643
{
47-
return ((Int_3_Delegate)Marshal.GetDelegateForFunctionPointer(fp, typeof(Int_3_Delegate)))(a1, a2, a3);
44+
return ((Interop.ObjObjArgFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(Interop.ObjObjArgFunc)))(a1, a2, a3);
4845
}
4946
#else
5047
private static AssemblyBuilder aBuilder;

src/tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111

1212
import pytest
1313
import clr
14+
from System.Runtime.InteropServices import RuntimeInformation
1415

1516
# Add path for `Python.Test`
1617
cwd = os.path.dirname(__file__)
17-
fixtures_path = os.path.join(cwd, "fixtures")
18+
if RuntimeInformation.FrameworkDescription.startswith(".NET Core"):
19+
fixtures_path = os.path.join(cwd, "fixtures/netstandard2.0")
20+
else:
21+
fixtures_path = os.path.join(cwd, "fixtures")
1822
sys.path.append(fixtures_path)
1923

2024
# Add References for tests
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""Helper script to test argv.
4+
Ensures that argv isn't modified after importing clr.
5+
For more details see GH#404 - argv not found"""
6+
7+
from __future__ import print_function
8+
9+
import sys
10+
import clr
11+
12+
print(sys.argv)

0 commit comments

Comments
 (0)
0