@@ -27,6 +27,7 @@ public void Dispose()
27
27
28
28
static IEnumerable < string [ ] > MyTestCases ( )
29
29
{
30
+ yield return new [ ] { "test_enum" , "test_enum_standard_attrs" } ;
30
31
yield return new [ ] { "test_generic" , "test_missing_generic_type" } ;
31
32
}
32
33
@@ -43,11 +44,25 @@ public void EmbeddedPythonTest(string testFile, string testName)
43
44
string path = Path . Combine ( folder , testFile + ".py" ) ;
44
45
if ( ! File . Exists ( path ) ) throw new FileNotFoundException ( "Cannot find test file" , path ) ;
45
46
47
+ // importlib gives more helpful error messages than 'import'
48
+ // https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
46
49
PythonEngine . Exec ( $@ "
47
50
import sys
48
- sys.path.insert(0, r'{ folder } ')
49
- import{ testFile }
50
- { testFile } .{ testName } ()
51
+ import os
52
+ fixtures_path = os.path.join(r'{ folder } ', 'fixtures')
53
+ sys.path.append(fixtures_path)
54
+ import clr
55
+ clr.AddReference('Python.Test')
56
+ sys.path.append(r'{ folder } ')
57
+ import utils
58
+ module_name = '{ testFile } '
59
+ file_path = r'{ path } '
60
+ import importlib.util
61
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
62
+ module = importlib.util.module_from_spec(spec)
63
+ sys.modules[module_name] = module
64
+ spec.loader.exec_module(module)
65
+ module.{ testName } ()
51
66
" ) ;
52
67
}
53
68
}