File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ internal static void RestoreRuntimeData(RuntimeDataStorage storage)
109
109
storage . GetValue ( "py_clr_module" , out py_clr_module ) ;
110
110
var rootHandle = storage . GetValue < IntPtr > ( "root" ) ;
111
111
root = ( CLRModule ) ManagedType . GetManagedObject ( rootHandle ) ;
112
+ IntPtr dict = Runtime . PyImport_GetModuleDict ( ) ;
113
+ Runtime . PyDict_SetItemString ( dict , "CLR" , py_clr_module ) ;
114
+ Runtime . PyDict_SetItemString ( dict , "clr" , py_clr_module ) ;
112
115
SetupNamespaceTracking ( ) ;
113
116
}
114
117
Original file line number Diff line number Diff line change @@ -1092,6 +1092,46 @@ assert sys.my_obj is not None
1092
1092
foo = sys.my_obj.Inner()
1093
1093
print(foo)
1094
1094
1095
+ " ,
1096
+ } ,
1097
+ new TestCase
1098
+ {
1099
+ // The C# code for this test doesn't matter.
1100
+ Name = "import_after_reload" ,
1101
+ DotNetBefore = @"
1102
+ namespace TestNamespace
1103
+ {
1104
+ [System.Serializable]
1105
+ public class Cls
1106
+ {
1107
+ }
1108
+ }" ,
1109
+ DotNetAfter = @"
1110
+ namespace TestNamespace
1111
+ {
1112
+ [System.Serializable]
1113
+ public class WithNestedType
1114
+ {
1115
+ [System.Serializable]
1116
+ public class Cls
1117
+ {
1118
+ }
1119
+ }
1120
+ }" ,
1121
+ PythonCode = @"
1122
+ import sys
1123
+
1124
+ def before_reload():
1125
+ import clr
1126
+ import System
1127
+
1128
+
1129
+ def after_reload():
1130
+ assert 'System' in sys.modules
1131
+ assert 'clr' in sys.modules
1132
+ import clr
1133
+ import System
1134
+
1095
1135
" ,
1096
1136
} ,
1097
1137
} ;
Original file line number Diff line number Diff line change @@ -88,3 +88,7 @@ def test_in_to_ref_param():
88
88
89
89
def test_nested_type ():
90
90
_run_test ("nested_type" )
91
+
92
+ @pytest .mark .skipif (platform .system () == 'Darwin' , reason = 'FIXME: macos can\' t find the python library' )
93
+ def test_import_after_reload ():
94
+ _run_test ("import_after_reload" )
You can’t perform that action at this time.
0 commit comments