Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59fa6a8

Browse files
committed
Adjust the import tests to use only commonly available deps
1 parent5cc8faa commit59fa6a8

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

‎tests/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ def pytest_configure(config):
6666

6767
importclr
6868
clr.AddReference("Python.Test")
69-
clr.AddReference("System")
70-
clr.AddReference("System.Collections")
71-
clr.AddReference("System.Data")
72-
clr.AddReference("System.Xml")
7369

7470

7571
defpytest_unconfigure(config):

‎tests/test_module.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_import_clr():
3030

3131
deftest_version_clr():
3232
importclr
33-
assertclr.__version__>="2.2.0"
33+
assertclr.__version__>="3.0.0"
3434

3535

3636
deftest_preload_var():
@@ -111,12 +111,13 @@ def test_dotted_name_import():
111111

112112
deftest_multiple_dotted_name_import():
113113
"""Test an import bug with multiple dotted imports."""
114-
importSystem.Data
115-
assertis_clr_module(System.Data)
116-
assertSystem.Data.__name__=='System.Data'
117-
importSystem.Data
118-
assertis_clr_module(System.Data)
119-
assertSystem.Data.__name__=='System.Data'
114+
115+
importSystem.Reflection
116+
assertis_clr_module(System.Reflection)
117+
assertSystem.Reflection.__name__=='System.Reflection'
118+
importSystem.Reflection
119+
assertis_clr_module(System.Reflection)
120+
assertSystem.Reflection.__name__=='System.Reflection'
120121

121122

122123
deftest_dotted_name_import_with_alias():
@@ -192,11 +193,11 @@ def test_dotted_name_import_from_with_alias():
192193

193194
deftest_from_module_import_star():
194195
"""Test from module import * behavior."""
195-
clr.AddReference('System.Xml')
196-
196+
clr.AddReference("System")
197+
197198
count=len(locals().keys())
198-
m=__import__('System.Xml',globals(),locals(), ['*'])
199-
assertm.__name__=='System.Xml'
199+
m=__import__('System',globals(),locals(), ['*'])
200+
assertm.__name__=='System'
200201
assertis_clr_module(m)
201202
assertlen(locals().keys())>count+1
202203

@@ -212,7 +213,11 @@ def test_implicit_assembly_load():
212213
importMicrosoft.Build
213214

214215
withwarnings.catch_warnings(record=True)asw:
215-
clr.AddReference("System.Windows.Forms")
216+
try:
217+
clr.AddReference("System.Windows.Forms")
218+
exceptException:
219+
pytest.skip()
220+
216221
importSystem.Windows.FormsasForms
217222
assertis_clr_module(Forms)
218223
assertForms.__name__=='System.Windows.Forms'
@@ -227,11 +232,11 @@ def test_explicit_assembly_load():
227232
fromSystem.ReflectionimportAssembly
228233
importSystem,sys
229234

230-
assembly=Assembly.LoadWithPartialName('System.Data')
235+
assembly=Assembly.LoadWithPartialName('System.Runtime')
231236
assertassemblyisnotNone
232237

233-
importSystem.Data
234-
assert'System.Data'insys.modules
238+
importSystem.Runtime
239+
assert'System.Runtime'insys.modules
235240

236241
assembly=Assembly.LoadWithPartialName('SpamSpamSpamSpamEggsAndSpam')
237242
assertassemblyisNone
@@ -275,12 +280,14 @@ def test_module_lookup_recursion():
275280

276281
deftest_module_get_attr():
277282
"""Test module getattr behavior."""
283+
278284
importSystem
285+
importSystem.Runtime
279286

280287
int_type=System.Int32
281288
assertis_clr_class(int_type)
282289

283-
module=System.Xml
290+
module=System.Runtime
284291
assertis_clr_module(module)
285292

286293
withpytest.raises(AttributeError):
@@ -324,7 +331,6 @@ def test_clr_list_assemblies():
324331
fromclrimportListAssemblies
325332
verbose=list(ListAssemblies(True))
326333
short=list(ListAssemblies(False))
327-
assertu'mscorlib'inshort
328334
assertu'System'inshort
329335
assertu'Culture='inverbose[0]
330336
assertu'Version='inverbose[0]
@@ -377,8 +383,11 @@ def test_assembly_load_thread_safety():
377383
_=Dictionary[Guid,DateTime]()
378384
ModuleTest.JoinThreads()
379385

386+
@pytest.mark.skipif()
380387
deftest_assembly_load_recursion_bug():
381388
"""Test fix for recursion bug documented in #627"""
382-
fromSystem.ConfigurationimportConfigurationManager
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)
384393
assertlen(content)>5,content

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp