| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,17 +59,12 @@ def test_class_default_repr(self): | |||
| 59 | 59 | ||
| 60 | 60 | def test_non_public_class(self): | |
| 61 | 61 | """Test that non-public classes are inaccessible.""" | |
| 62 | - | ||
| 63 | - def test(): | ||
| 62 | + with self.assertRaises(ImportError): | ||
| 64 | 63 | from Python.Test import InternalClass | |
| 65 | 64 | ||
| 66 | - self.assertRaises(ImportError, test) | ||
| 67 | - | ||
| 68 | - def test(): | ||
| 65 | + with self.assertRaises(AttributeError): | ||
| 69 | 66 | x = Test.InternalClass | |
| 70 | 67 | ||
| 71 | - self.assertRaises(AttributeError, test) | ||
| 72 | - | ||
| 73 | 68 | def test_basic_subclass(self): | |
| 74 | 69 | """Test basic subclass of a managed class.""" | |
| 75 | 70 | from System.Collections import Hashtable | |
@@ -256,13 +251,17 @@ def test_comparisons(self): | |||
| 256 | 251 | self.assertEqual(d2 >= d1, True) | |
| 257 | 252 | self.assertEqual(d2 > d1, True) | |
| 258 | 253 | ||
| 259 | - self.assertRaises(TypeError, lambda: d1 < None) | ||
| 260 | - self.assertRaises(TypeError, lambda: d1 < System.Guid()) | ||
| 254 | + with self.assertRaises(TypeError): | ||
| 255 | + d1 < None | ||
| 256 | + | ||
| 257 | + with self.assertRaises(TypeError): | ||
| 258 | + d1 < System.Guid() | ||
| 261 | 259 | ||
| 262 | 260 | # ClassTest does not implement IComparable | |
| 263 | 261 | c1 = ClassTest() | |
| 264 | 262 | c2 = ClassTest() | |
| 265 | - self.assertRaises(TypeError, lambda: c1 < c2) | ||
| 263 | + with self.assertRaises(TypeError): | ||
| 264 | + c1 < c2 | ||
| 266 | 265 | ||
| 267 | 266 | def test_self_callback(self): | |
| 268 | 267 | """Test calling back and forth between this and a c# baseclass.""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,17 +182,13 @@ def test_implicit_load_already_valid_namespace(self): | |||
| 182 | 182 | self.assertTrue(isCLRClass(CLR.System.UriBuilder)) | |
| 183 | 183 | ||
| 184 | 184 | 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): | ||
| 188 | 187 | import System.SpamSpamSpam | |
| 189 | 188 | ||
| 190 | - def testclr(): | ||
| 189 | + with self.assertRaises(ImportError): | ||
| 191 | 190 | import CLR.System.SpamSpamSpam | |
| 192 | 191 | ||
| 193 | - self.assertRaises(ImportError, test) | ||
| 194 | - self.assertRaises(ImportError, testclr) | ||
| 195 | - | ||
| 196 | 192 | def test_lookup_no_namespace_type(self): | |
| 197 | 193 | """Test lookup of types without a qualified namespace.""" | |
| 198 | 194 | import CLR.Python.Test | |
@@ -201,18 +197,13 @@ def test_lookup_no_namespace_type(self): | |||
| 201 | 197 | ||
| 202 | 198 | def test_module_lookup_recursion(self): | |
| 203 | 199 | """Test for recursive lookup handling.""" | |
| 204 | - | ||
| 205 | - def test1(): | ||
| 200 | + with self.assertRaises(ImportError): | ||
| 206 | 201 | from CLR import CLR | |
| 207 | 202 | ||
| 208 | - self.assertRaises(ImportError, test1) | ||
| 209 | - | ||
| 210 | - def test2(): | ||
| 203 | + with self.assertRaises(AttributeError): | ||
| 211 | 204 | import CLR | |
| 212 | 205 | x = CLR.CLR | |
| 213 | 206 | ||
| 214 | - self.assertRaises(AttributeError, test2) | ||
| 215 | - | ||
| 216 | 207 | def test_module_get_attr(self): | |
| 217 | 208 | """Test module getattr behavior.""" | |
| 218 | 209 | import CLR.System as System | |
@@ -223,20 +214,16 @@ def test_module_get_attr(self): | |||
| 223 | 214 | module = System.Xml | |
| 224 | 215 | self.assertTrue(isCLRModule(module)) | |
| 225 | 216 | ||
| 226 | - def test(): | ||
| 217 | + with self.assertRaises(AttributeError): | ||
| 227 | 218 | spam = System.Spam | |
| 228 | 219 | ||
| 229 | - self.assertRaises(AttributeError, test) | ||
| 230 | - | ||
| 231 | - def test(): | ||
| 220 | + with self.assertRaises(TypeError): | ||
| 232 | 221 | spam = getattr(System, 1) | |
| 233 | 222 | ||
| 234 | - self.assertRaises(TypeError, test) | ||
| 235 | - | ||
| 236 | - def test000_multiple_imports(self): | ||
| 223 | + def test_multiple_imports(self): | ||
| 237 | 224 | # import CLR did raise a Seg Fault once | |
| 238 | 225 | # test if the Exceptions.warn() method still causes it | |
| 239 | - for n in range(100): | ||
| 226 | + for _ in range(100): | ||
| 240 | 227 | import CLR | |
| 241 | 228 | ||
| 242 | 229 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments