diff options
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r-- | Lib/test/test_long.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index ffa4774..b65d24c 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -79,6 +79,12 @@ if test_support.have_unicode: (unichr(0x200), ValueError), ] +class LongSubclass(long): + pass + +class OtherLongSubclass(long): + pass + class LongTest(test_int.IntLongCommonTests, unittest.TestCase): ntype = long @@ -539,6 +545,17 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase): self.fail("Failed to raise TypeError with %s" % ((base, trunc_result_base),)) + class TruncReturnsLongSubclass(base): + def __long__(self): + return OtherLongSubclass(42L) + good_int = TruncReturnsLongSubclass() + n = long(good_int) + self.assertEqual(n, 42L) + self.assertIs(type(n), OtherLongSubclass) + n = LongSubclass(good_int) + self.assertEqual(n, 42L) + self.assertIs(type(n), LongSubclass) + def test_misc(self): # check the extremes in int<->long conversion |