OLD | NEW |
1 import sys | 1 import sys |
2 | 2 |
3 import unittest | 3 import unittest |
4 from test.support import run_unittest | 4 from test.support import run_unittest |
5 | 5 |
6 L = [ | 6 L = [ |
7 ('0', 0), | 7 ('0', 0), |
8 ('1', 1), | 8 ('1', 1), |
9 ('9', 9), | 9 ('9', 9), |
10 ('10', 10), | 10 ('10', 10), |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 def __trunc__(self): | 288 def __trunc__(self): |
289 # Check that we avoid infinite recursion. | 289 # Check that we avoid infinite recursion. |
290 return NonIntegral() | 290 return NonIntegral() |
291 | 291 |
292 class TruncReturnsNonIntegral(base): | 292 class TruncReturnsNonIntegral(base): |
293 def __trunc__(self): | 293 def __trunc__(self): |
294 return NonIntegral() | 294 return NonIntegral() |
295 try: | 295 try: |
296 int(TruncReturnsNonIntegral()) | 296 int(TruncReturnsNonIntegral()) |
297 except TypeError as e: | 297 except TypeError as e: |
298 self.assertEquals(str(e), | 298 self.assertEqual(str(e), |
299 "__trunc__ returned non-Integral" | 299 "__trunc__ returned non-Integral" |
300 " (type NonIntegral)") | 300 " (type NonIntegral)") |
301 else: | 301 else: |
302 self.fail("Failed to raise TypeError with %s" % | 302 self.fail("Failed to raise TypeError with %s" % |
303 ((base, trunc_result_base),)) | 303 ((base, trunc_result_base),)) |
304 | 304 |
305 def test_main(): | 305 def test_main(): |
306 run_unittest(IntTestCases) | 306 run_unittest(IntTestCases) |
307 | 307 |
308 if __name__ == "__main__": | 308 if __name__ == "__main__": |
309 test_main() | 309 test_main() |
OLD | NEW |