33using System . Collections . Generic ;
44using NUnit . Framework ;
55using Python . Runtime ;
6+ using System . IO ;
67
78namespace Python . 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 const string s = @"../../../../tests" ;
2826
29- Type RTClass = typeof ( Runtime . Runtime ) ;
30-
31- /* pyStrPtr = PyString_FromString(s); */
32- MethodInfo PyString_FromString = RTClass . GetMethod ( "PyString_FromString" ,
33- BindingFlags . NonPublic | BindingFlags . Static ) ;
34- object [ ] funcArgs = new object [ 1 ] ;
35- funcArgs [ 0 ] = s ;
36- IntPtr pyStrPtr = ( IntPtr ) PyString_FromString . Invoke ( null , funcArgs ) ;
37-
38- /* SysDotPath = sys.path */
39- MethodInfo PySys_GetObject = RTClass . GetMethod ( "PySys_GetObject" ,
40- BindingFlags . NonPublic | BindingFlags . Static ) ;
41- funcArgs [ 0 ] = "path" ;
42- IntPtr SysDotPath = ( IntPtr ) PySys_GetObject . Invoke ( null , funcArgs ) ;
27+ var testPath = Path . Combine (
28+ TestContext . CurrentContext . TestDirectory , s
29+ ) ;
4330
44- /* SysDotPath.append(*pyStrPtr) */
45- MethodInfo PyList_Append = RTClass . GetMethod ( "PyList_Append" , BindingFlags . NonPublic | BindingFlags . Static ) ;
46- funcArgs = new object [ ] { SysDotPath , pyStrPtr } ;
47- int r = ( int ) PyList_Append . Invoke ( null , funcArgs ) ;
31+ IntPtr str = Runtime . Runtime . PyString_FromString ( testPath ) ;
32+ IntPtr path = Runtime . Runtime . PySys_GetObject ( "path" ) ;
33+ Runtime . Runtime . PyList_Append ( path , str ) ;
4834 }
4935
5036 [ TearDown ]
0 commit comments