8000 EmbeddedPythonTest is smarter about finding the tests directory · pythonnet/pythonnet@bb7ff4d · GitHub
[go: up one dir, main page]

Skip to content

Commit bb7ff4d

Browse files
committed
EmbeddedPythonTest is smarter about finding the tests directory
1 parent 3960423 commit bb7ff4d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/embed_tests/TestPythonTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ static IEnumerable<string[]> MyTestCases()
3131
[TestCaseSource(nameof(MyTestCases))]
3232
public void EmbeddedPythonTest(string testFile, string testName)
3333
{
34-
string folder = @"..\\..\\..\\..\\tests";
34+
// Find the tests directory
35+
string folder = Directory.GetCurrentDirectory();
36+
while(Path.GetFileName(folder) != "src")
37+
{
38+
folder = Path.GetDirectoryName(folder);
39+
}
40+
folder = Path.Combine(folder, "tests");
41+
3542
PythonEngine.Exec($@"
3643
import sys
37-
sys.path.insert(0, '{folder}')
44+
sys.path.insert(0, r'{folder}')
3845
from {testFile} import *
3946
{testName}()
4047
");

0 commit comments

Comments
 (0)
0