@@ -30,7 +30,7 @@ def test_import_clr():
30
30
31
31
def test_version_clr ():
32
32
import clr
33
- assert clr .__version__ >= "2.2 .0"
33
+ assert clr .__version__ >= "3.0 .0"
34
34
35
35
36
36
def test_preload_var ():
@@ -111,12 +111,13 @@ def test_dotted_name_import():
111
111
112
112
def test_multiple_dotted_name_import ():
113
113
"""Test an import bug with multiple dotted imports."""
114
- import System .Data
115
- assert is_clr_module (System .Data )
116
- assert System .Data .__name__ == 'System.Data'
117
- import System .Data
118
- assert is_clr_module (System .Data )
119
- assert System .Data .__name__ == 'System.Data'
114
+
115
+ import System .Reflection
116
+ assert is_clr_module (System .Reflection )
117
+ assert System .Reflection .__name__ == 'System.Reflection'
118
+ import System .Reflection
119
+ assert is_clr_module (System .Reflection )
120
+ assert System .Reflection .__name__ == 'System.Reflection'
120
121
121
122
122
123
def test_dotted_name_import_with_alias ():
@@ -192,11 +193,11 @@ def test_dotted_name_import_from_with_alias():
192
193
193
194
def test_from_module_import_star ():
194
195
"""Test from module import * behavior."""
195
- clr .AddReference (' System.Xml' )
196
-
196
+ clr .AddReference (" System" )
197
+
197
198
count = len (locals ().keys ())
198
- m = __import__ ('System.Xml ' , globals (), locals (), ['*' ])
199
- assert m .__name__ == 'System.Xml '
199
+ m = __import__ ('System' , globals (), locals (), ['*' ])
200
+ assert m .__name__ == 'System'
200
201
assert is_clr_module (m )
201
202
assert len (locals ().keys ()) > count + 1
202
203
@@ -212,7 +213,11 @@ def test_implicit_assembly_load():
212
213
import Microsoft .Build
213
214
214
215
with warnings .catch_warnings (record = True ) as w :
215
- clr .AddReference ("System.Windows.Forms" )
216
+ try :
217
+ clr .AddReference ("System.Windows.Forms" )
218
+ except Exception :
219
+ pytest .skip ()
220
+
216
221
import System .Windows .Forms as Forms
217
222
assert is_clr_module (Forms )
218
223
assert Forms .__name__ == 'System.Windows.Forms'
@@ -227,11 +232,11 @@ def test_explicit_assembly_load():
227
232
from System .Reflection import Assembly
228
233
import System , sys
229
234
230
- assembly = Assembly .LoadWithPartialName ('System.Data ' )
235
+ assembly = Assembly .LoadWithPartialName ('System.Runtime ' )
231
236
assert assembly is not None
232
237
233
- import System .Data
234
- assert 'System.Data ' in sys .modules
238
+ import System .Runtime
239
+ assert 'System.Runtime ' in sys .modules
235
240
236
241
assembly = Assembly .LoadWithPartialName ('SpamSpamSpamSpamEggsAndSpam' )
237
242
assert assembly is None
@@ -275,12 +280,14 @@ def test_module_lookup_recursion():
275
280
276
281
def test_module_get_attr ():
277
282
"""Test module getattr behavior."""
283
+
278
284
import System
285
+ import System .Runtime
279
286
280
287
int_type = System .Int32
281
288
assert is_clr_class (int_type )
282
289
283
- module = System .Xml
290
+ module = System .Runtime
284
291
assert is_clr_module (module )
285
292
286
293
with pytest .raises (AttributeError ):
@@ -324,7 +331,6 @@ def test_clr_list_assemblies():
324
331
from clr import ListAssemblies
325
332
verbose = list (ListAssemblies (True ))
326
333
short = list (ListAssemblies (False ))
327
- assert u'mscorlib' in short
328
334
assert u'System' in short
329
335
assert u'Culture=' in verbose [0 ]
330
336
assert u'Version=' in verbose [0 ]
@@ -377,8 +383,11 @@ def test_assembly_load_thread_safety():
377
383
_ = Dictionary [Guid , DateTime ]()
378
384
ModuleTest .JoinThreads ()
379
385
386
+ @pytest .mark .skipif ()
380
387
def test_assembly_load_recursion_bug ():
381
388
"""Test fix for recursion bug documented in #627"""
382
- from System .Configuration import ConfigurationManager
383
- content = dir (ConfigurationManager )
389
+ sys_config = pytest .importorskip (
390
+ "System.Configuration" , reason = "System.Configuration can't be imported"
391
+ )
392
+ content = dir (sys_config .ConfigurationManager )
384
393
assert len (content ) > 5 , content
0 commit comments