Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 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
Prev Previous commit
Next Next commit
Fix PythonTestRunner to work with new pytest setup
  • Loading branch information
filmor committed Feb 14, 2021
commit f0011a51fd494740f9768caf2074e5275ae7a0d1
1 change: 1 addition & 0 deletions src/python_tests_runner/Python.PythonTestsRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
<ProjectReference Include="..\testing\Python.Test.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/python_tests_runner/PythonTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using NUnit.Framework;

using Python.Runtime;
using Python.Test;

namespace Python.PythonTestsRunner
{
Expand Down Expand Up @@ -50,7 +51,7 @@ public void RunPythonTest(string testFile, string testName)
{
folder = Path.GetDirectoryName(folder);
}
folder = Path.Combine(folder, "tests");
folder = Path.Combine(folder, "..", "tests");
string path = Path.Combine(folder, testFile + ".py");
if (!File.Exists(path)) throw new FileNotFoundException("Cannot find test file", path);

Expand Down
11 changes: 10 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def pytest_addoption(parser):

def pytest_configure(config):
global bin_path
if "clr" in sys.modules:
# Already loaded (e.g. by the C# test runner), skip build
import clr
clr.AddReference("Python.Test")
return

runtime_opt = config.getoption("runtime")

test_proj_path = os.path.join(cwd, "..", "src", "testing")
Expand Down Expand Up @@ -70,7 +76,10 @@ def pytest_configure(config):

def pytest_unconfigure(config):
global bin_path
shutil.rmtree(bin_path)
try:
shutil.rmtree(bin_path)
except Exception:
pass

def pytest_report_header(config):
"""Generate extra report headers"""
Expand Down