summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_int.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_int.py')
-rw-r--r--Lib/test/test_int.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index 2ca6cf2..0dd8efc 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -45,6 +45,9 @@ if have_unicode:
(unichr(0x200), ValueError),
]
+class IntSubclass(int):
+ pass
+
class IntLongCommonTests(object):
"""Mixin of test cases to share between both test_int and test_long."""
@@ -477,6 +480,18 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.fail("Failed to raise TypeError with %s" %
((base, trunc_result_base),))
+ class TruncReturnsIntSubclass(base):
+ def __trunc__(self):
+ return True
+ good_int = TruncReturnsIntSubclass()
+ n = int(good_int)
+ self.assertEqual(n, 1)
+ self.assertIs(type(n), bool)
+ n = IntSubclass(good_int)
+ self.assertEqual(n, 1)
+ self.assertIs(type(n), IntSubclass)
+
+
def test_main():
run_unittest(IntTestCases)