@@ -182,17 +182,13 @@ def test_implicit_load_already_valid_namespace(self):
182182 self .assertTrue (isCLRClass (CLR .System .UriBuilder ))
183183
184184 def test_import_non_existant_module (self ):
185- """Test import failure for a non-existant module."""
186-
187- def test ():
185+ """Test import failure for a non-existent module."""
186+ with self .assertRaises (ImportError ):
188187 import System .SpamSpamSpam
189188
190- def testclr ( ):
189+ with self . assertRaises ( ImportError ):
191190 import CLR .System .SpamSpamSpam
192191
193- self .assertRaises (ImportError , test )
194- self .assertRaises (ImportError , testclr )
195-
196192 def test_lookup_no_namespace_type (self ):
197193 """Test lookup of types without a qualified namespace."""
198194 import CLR .Python .Test
@@ -201,18 +197,13 @@ def test_lookup_no_namespace_type(self):
201197
202198 def test_module_lookup_recursion (self ):
203199 """Test for recursive lookup handling."""
204-
205- def test1 ():
200+ with self .assertRaises (ImportError ):
206201 from CLR import CLR
207202
208- self .assertRaises (ImportError , test1 )
209-
210- def test2 ():
203+ with self .assertRaises (AttributeError ):
211204 import CLR
212205 x = CLR .CLR
213206
214- self .assertRaises (AttributeError , test2 )
215-
216207 def test_module_get_attr (self ):
217208 """Test module getattr behavior."""
218209 import CLR .System as System
@@ -223,20 +214,16 @@ def test_module_get_attr(self):
223214 module = System .Xml
224215 self .assertTrue (isCLRModule (module ))
225216
226- def test ( ):
217+ with self . assertRaises ( AttributeError ):
227218 spam = System .Spam
228219
229- self .assertRaises (AttributeError , test )
230-
231- def test ():
220+ with self .assertRaises (TypeError ):
232221 spam = getattr (System , 1 )
233222
234- self .assertRaises (TypeError , test )
235-
236- def test000_multiple_imports (self ):
223+ def test_multiple_imports (self ):
237224 # import CLR did raise a Seg Fault once
238225 # test if the Exceptions.warn() method still causes it
239- for n in range (100 ):
226+ for _ in range (100 ):
240227 import CLR
241228
242229
0 commit comments