Skip to content

Commit 34a1705

Browse files
committed
Fix embedding tests
1 parent a068a4d commit 34a1705

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
99
</ItemGroup>
1010

11+
<ItemGroup>
12+
<None Include="fixtures/**/*.py" CopyToOutputDirectory="PreserveNewest" />
13+
</ItemGroup>
14+
1115
<ItemGroup>
1216
<PackageReference Include="NUnit" Version="3.*" />
1317
<PackageReference Include="NUnit3TestAdapter" Version="3.*">

src/embed_tests/TestDomainReload.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ static Assembly BuildAssembly(string assemblyName)
118118

119119
var compilerparams = new CompilerParameters();
120120
compilerparams.ReferencedAssemblies.Add("Python.Runtime.dll");
121+
var netstandard = Assembly.Load("netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51");
122+
compilerparams.ReferencedAssemblies.Add(netstandard.Location);
121123
compilerparams.GenerateExecutable = false;
122124
compilerparams.GenerateInMemory = false;
123125
compilerparams.IncludeDebugInformation = false;

src/embed_tests/TestPyWith.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ public void Dispose()
2525
public void TestWithPositive()
2626
{
2727
var locals = new PyDict();
28-
28+
2929
PythonEngine.Exec(@"
3030
class CmTest:
3131
def __enter__(self):
32-
print('Enter')
3332
return self
3433
def __exit__(self, t, v, tb):
3534
# Exception not handled, return will be False
36-
print('Exit')
35+
pass
3736
def fail(self):
3837
return 5 / 0
3938
@@ -51,6 +50,7 @@ def fail(self):
5150
}
5251
catch (PythonException e)
5352
{
53+
TestContext.Out.WriteLine(e.Message);
5454
Assert.IsTrue(e.Message.Contains("ZeroDivisionError"));
5555
}
5656
}

src/embed_tests/pyimport.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ public void SetUp()
3030
/* Append the tests directory to sys.path
3131
* using reflection to circumvent the private
3232
* modifiers placed on most Runtime methods. */
33-
#if NETCOREAPP
34-
const string s = "../../fixtures";
35-
#else
36-
const string s = "../fixtures";
37-
#endif
38-
string testPath = Path.Combine(TestContext.CurrentContext.TestDirectory, s);
33+
string testPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "fixtures");
34+
TestContext.Out.WriteLine(testPath);
3935

4036
IntPtr str = Runtime.Runtime.PyString_FromString(testPath);
4137
BorrowedReference path = Runtime.Runtime.PySys_GetObject("path");

0 commit comments

Comments
 (0)