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)
109109 storage . GetValue ( "py_clr_module" , out py_clr_module ) ;
110110 var rootHandle = storage . GetValue < IntPtr > ( "root" ) ;
111111 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 ) ;
112115 SetupNamespaceTracking ( ) ;
113116 }
114117
Original file line number Diff line number Diff line change @@ -1092,6 +1092,46 @@ assert sys.my_obj is not None
10921092 foo = sys.my_obj.Inner()
10931093 print(foo)
10941094
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+
10951135 " ,
10961136 } ,
10971137 } ;
Original file line number Diff line number Diff line change @@ -88,3 +88,7 @@ def test_in_to_ref_param():
8888
8989def test_nested_type ():
9090 _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