@@ -27,7 +27,6 @@ public void Dispose()
27
27
28
28
static IEnumerable < string [ ] > MyTestCases ( )
29
29
{
30
- yield return new [ ] { "test_enum" , "test_enum_standard_attrs" } ;
31
30
yield return new [ ] { "test_generic" , "test_missing_generic_type" } ;
32
31
}
33
32
@@ -44,18 +43,21 @@ public void EmbeddedPythonTest(string testFile, string testName)
44
43
string path = Path . Combine ( folder , testFile + ".py" ) ;
45
44
if ( ! File . Exists ( path ) ) throw new FileNotFoundException ( "Cannot find test file" , path ) ;
46
45
47
- // importlib gives more helpful error messages than 'import'
46
+ //We could use 'import' below, but importlib gives more helpful error messages than 'import'
48
47
// https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
48
+ // Sometimes sys.path does not contain the site-packages directory, so we add it explicitly
49
+ // Because the Python tests sometimes have relative imports, the module name must be inside the tests package
49
50
PythonEngine . Exec ( $@ "
50
51
import sys
51
52
import os
52
- fixtures_path = os.path.join(r'{ folder } ', 'fixtures')
53
- sys.path.append(fixtures_path)
53
+ libdir = os.path.dirname(sys.modules['os'].__file__)
54
+ sys.path.append(os.path.join(libdir, 'site-packages'))
55
+ sys.path.append(os.path.dirname(r'{ folder } '))
56
+ sys.path.append(os.path.join(r'{ folder } ', 'fixtures'))
54
57
import clr
55
58
clr.AddReference('Python.Test')
56
- sys.path.append(r'{ folder } ')
57
- import utils
58
- module_name = '{ testFile } '
59
+ import tests
60
+ module_name = 'tests.{ testFile } '
59
61
file_path = r'{ path } '
60
62
import importlib.util
61
63
spec = importlib.util.spec_from_file_location(module_name, file_path)