@@ -76,27 +76,15 @@ def test_coreclr(example_netcore: Path):
76
76
77
77
78
78
def test_coreclr_properties (example_netcore : Path ):
79
- from multiprocessing import get_context
80
-
81
- p = get_context ("spawn" ).Process (
82
- target = _do_test_coreclr_autogenerated_runtimeconfig ,
83
- args = (example_netstandard ,),
84
- kwargs = dict (properties = dict (APP_CONTEXT_BASE_DIRECTORY = str (example_netcore ))),
79
+ run_in_subprocess (
80
+ _do_test_coreclr_autogenerated_runtimeconfig ,
81
+ example_netstandard ,
82
+ properties = dict (APP_CONTEXT_BASE_DIRECTORY = str (example_netcore )),
85
83
)
86
- p .start ()
87
- p .join ()
88
- p .close ()
89
84
90
85
91
86
def test_coreclr_autogenerated_runtimeconfig (example_netstandard : Path ):
92
- from multiprocessing import get_context
93
-
94
- p = get_context ("spawn" ).Process (
95
- target = _do_test_coreclr_autogenerated_runtimeconfig , args = (example_netstandard ,)
96
- )
97
- p .start ()
98
- p .join ()
99
- p .close ()
87
+ run_in_subprocess (_do_test_coreclr_autogenerated_runtimeconfig , example_netstandard )
100
88
101
89
102
90
def _do_test_coreclr_autogenerated_runtimeconfig (
@@ -114,25 +102,31 @@ def _do_test_coreclr_autogenerated_runtimeconfig(
114
102
sys .platform != "win32" , reason = ".NET Framework only exists on Windows"
115
103
)
116
104
def test_netfx (example_netstandard : Path ):
117
- from clr_loader import get_netfx
118
-
119
- netfx = get_netfx ()
120
- asm = netfx .get_assembly (example_netstandard / "example.dll" )
121
-
122
- run_tests (asm )
105
+ run_in_subprocess (_do_test_netfx , example_netstandard )
123
106
124
107
125
108
@pytest .mark .skipif (
126
109
sys .platform != "win32" , reason = ".NET Framework only exists on Windows"
127
110
)
128
111
def test_netfx_chinese_path (example_netstandard : Path , tmpdir_factory ):
129
- from clr_loader import get_netfx
130
-
131
112
tmp_path = Path (tmpdir_factory .mktemp ("example-中国" ))
132
113
shutil .copytree (example_netstandard , tmp_path , dirs_exist_ok = True )
133
114
134
- netfx = get_netfx ()
135
- asm = netfx .get_assembly (os .path .join (example_netstandard , "example.dll" ))
115
+ run_in_subprocess (_do_test_netfx , tmp_path )
116
+
117
+
118
+ @pytest .mark .skipif (
119
+ sys .platform != "win32" , reason = ".NET Framework only exists on Windows"
120
+ )
121
+ def test_netfx_separate_domain (example_netstandard ):
122
+ run_in_subprocess (_do_test_netfx , example_netstandard , domain = "some domain" )
123
+
124
+
125
+ def _do_test_netfx (example_netstandard , ** kwargs ):
126
+ from clr_loader import get_netfx
127
+
128
+ netfx = get_netfx (** kwargs )
129
+ asm = netfx .get_assembly (example_netstandard / "example.dll" )
136
130
137
131
run_tests (asm )
138
132
@@ -142,3 +136,12 @@ def run_tests(asm):
142
136
test_data = b"testy mctestface"
143
137
res = func (test_data )
144
138
assert res == len (test_data )
139
+
140
+
141
+ def run_in_subprocess (func , * args , ** kwargs ):
142
+ from multiprocessing import get_context
143
+
144
+ p = get_context ("spawn" ).Process (target = func , args = args , kwargs = kwargs )
145
+ p .start ()
146
+ p .join ()
147
+ p .close ()
0 commit comments