| OLD | NEW |
| 1 """Test descriptors, binary ops, etc. | 1 """Test descriptors, binary ops, etc. |
| 2 | 2 |
| 3 Made for Jython. | 3 Made for Jython. |
| 4 """ | 4 """ |
| 5 import types | 5 import types |
| 6 import unittest | 6 import unittest |
| 7 from test import test_support | 7 from test import test_support |
| 8 | 8 |
| 9 class Old: | 9 class Old: |
| 10 pass | 10 pass |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 except TypeError: | 65 except TypeError: |
| 66 pass | 66 pass |
| 67 else: | 67 else: |
| 68 self.assert_(False, "should have raised TypeError") | 68 self.assert_(False, "should have raised TypeError") |
| 69 try: | 69 try: |
| 70 foo = C(None) | 70 foo = C(None) |
| 71 except TypeError: | 71 except TypeError: |
| 72 pass | 72 pass |
| 73 else: | 73 else: |
| 74 self.assert_(False, "should have raised TypeError") | 74 self.assert_(False, "should have raised TypeError") |
| 75 |
| 76 def test_raising_custom_attribute_error(self): |
| 77 class Desc(object): |
| 78 def __get__(self, instance, type): |
| 79 raise AttributeError("Custom message") |
| 80 class Foo(object): |
| 81 desc = Desc() |
| 82 try: |
| 83 Foo().desc |
| 84 self.assert_(False) # Previous line should raise AttributteError |
| 85 except AttributeError, e: |
| 86 self.assertEquals("Custom message", str(e)) |
| 75 | 87 |
| 76 class SubclassDescrTestCase(unittest.TestCase): | 88 class SubclassDescrTestCase(unittest.TestCase): |
| 77 | 89 |
| 78 def test_subclass_cmp_right_op(self): | 90 def test_subclass_cmp_right_op(self): |
| 79 # Case 1: subclass of int | 91 # Case 1: subclass of int |
| 80 | 92 |
| 81 class B(int): | 93 class B(int): |
| 82 def __ge__(self, other): | 94 def __ge__(self, other): |
| 83 return "B.__ge__" | 95 return "B.__ge__" |
| 84 def __le__(self, other): | 96 def __le__(self, other): |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 307 |
| 296 | 308 |
| 297 def test_main(): | 309 def test_main(): |
| 298 test_support.run_unittest(TestDescrTestCase, | 310 test_support.run_unittest(TestDescrTestCase, |
| 299 SubclassDescrTestCase, | 311 SubclassDescrTestCase, |
| 300 InPlaceTestCase, | 312 InPlaceTestCase, |
| 301 DescrExceptionsTestCase) | 313 DescrExceptionsTestCase) |
| 302 | 314 |
| 303 if __name__ == '__main__': | 315 if __name__ == '__main__': |
| 304 test_main() | 316 test_main() |
| OLD | NEW |