summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_class.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-12 20:01:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-12 20:01:30 (GMT)
commitc2ccce791ccbe35bee0edea2dedabb0fc7ea5906 (patch)
treec31fcb2d158d17ab07038f26ec016b37e5b8cea0 /Lib/test/test_class.py
parentda0870c87aeb7843f0211d3fd9220f6f5b58f688 (diff)
parenta60c2fe4807e89a5844979fe46b3ea39572fc3be (diff)
downloadcpython-c2ccce791ccbe35bee0edea2dedabb0fc7ea5906.zip
cpython-c2ccce791ccbe35bee0edea2dedabb0fc7ea5906.tar.gz
cpython-c2ccce791ccbe35bee0edea2dedabb0fc7ea5906.tar.bz2
Issue #23641: Cleaned out legacy dunder names from tests and docs.
Fixed 2 to 3 porting bug in pynche.ColorDB. Added few tests for __truediv__, __floordiv__ and __matmul__.
Diffstat (limited to 'Lib/test/test_class.py')
-rw-r--r--Lib/test/test_class.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index c7003fb..fcac5c5 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -13,8 +13,12 @@ testmeths = [
"rsub",
"mul",
"rmul",
+ "matmul",
+ "rmatmul",
"truediv",
"rtruediv",
+ "floordiv",
+ "rfloordiv",
"mod",
"rmod",
"divmod",
@@ -174,15 +178,31 @@ class ClassTests(unittest.TestCase):
1 * testme
self.assertCallStack([("__rmul__", (testme, 1))])
- if 1/2 == 0:
- callLst[:] = []
- testme / 1
- self.assertCallStack([("__div__", (testme, 1))])
+ callLst[:] = []
+ testme @ 1
+ self.assertCallStack([("__matmul__", (testme, 1))])
+
+ callLst[:] = []
+ 1 @ testme
+ self.assertCallStack([("__rmatmul__", (testme, 1))])
+
+ callLst[:] = []
+ testme / 1
+ self.assertCallStack([("__truediv__", (testme, 1))])
- callLst[:] = []
- 1 / testme
- self.assertCallStack([("__rdiv__", (testme, 1))])
+ callLst[:] = []
+ 1 / testme
+ self.assertCallStack([("__rtruediv__", (testme, 1))])
+
+ callLst[:] = []
+ testme // 1
+ self.assertCallStack([("__floordiv__", (testme, 1))])
+
+
+ callLst[:] = []
+ 1 // testme
+ self.assertCallStack([("__rfloordiv__", (testme, 1))])
callLst[:] = []
testme % 1
@@ -444,12 +464,16 @@ class ClassTests(unittest.TestCase):
def __int__(self):
return None
__float__ = __int__
+ __complex__ = __int__
__str__ = __int__
__repr__ = __int__
- __oct__ = __int__
- __hex__ = __int__
+ __bytes__ = __int__
+ __bool__ = __int__
+ __index__ = __int__
+ def index(x):
+ return [][x]
- for f in [int, float, str, repr, oct, hex]:
+ for f in [float, complex, str, repr, bytes, bin, oct, hex, bool, index]:
self.assertRaises(TypeError, f, BadTypeClass())
def testHashStuff(self):