diff options
author | Guido van Rossum <guido@python.org> | 2003-02-27 20:04:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-02-27 20:04:19 (GMT) |
commit | f389c7727362321a91dbaff13b7e1cef6cbaa3d8 (patch) | |
tree | aaa05dcfbd97d3a34046b9b545a4659076386789 /Lib/test/test_descr.py | |
parent | f359410ce22749da69b8adb5a3c23f78876292c6 (diff) | |
download | cpython-f389c7727362321a91dbaff13b7e1cef6cbaa3d8.zip cpython-f389c7727362321a91dbaff13b7e1cef6cbaa3d8.tar.gz cpython-f389c7727362321a91dbaff13b7e1cef6cbaa3d8.tar.bz2 |
Use floor division (// and __[r]floordiv__ in right-dispatch test.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 5d15966..946a529 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3678,47 +3678,47 @@ def subclass_right_op(): # Case 1: subclass of int; this tests code in abstract.c::binary_op1() class B(int): - def __div__(self, other): - return "B.__div__" - def __rdiv__(self, other): - return "B.__rdiv__" + def __floordiv__(self, other): + return "B.__floordiv__" + def __rfloordiv__(self, other): + return "B.__rfloordiv__" - vereq(B(1) / 1, "B.__div__") - vereq(1 / B(1), "B.__rdiv__") + vereq(B(1) // 1, "B.__floordiv__") + vereq(1 // B(1), "B.__rfloordiv__") # Case 2: subclass of object; this is just the baseline for case 3 class C(object): - def __div__(self, other): - return "C.__div__" - def __rdiv__(self, other): - return "C.__rdiv__" + def __floordiv__(self, other): + return "C.__floordiv__" + def __rfloordiv__(self, other): + return "C.__rfloordiv__" - vereq(C() / 1, "C.__div__") - vereq(1 / C(), "C.__rdiv__") + vereq(C() // 1, "C.__floordiv__") + vereq(1 // C(), "C.__rfloordiv__") # Case 3: subclass of new-style class; here it gets interesting class D(C): - def __div__(self, other): - return "D.__div__" - def __rdiv__(self, other): - return "D.__rdiv__" + def __floordiv__(self, other): + return "D.__floordiv__" + def __rfloordiv__(self, other): + return "D.__rfloordiv__" - vereq(D() / C(), "D.__div__") - vereq(C() / D(), "D.__rdiv__") + vereq(D() // C(), "D.__floordiv__") + vereq(C() // D(), "D.__rfloordiv__") # Case 4: this didn't work right in 2.2.2 and 2.3a1 class E(C): pass - vereq(E.__rdiv__, C.__rdiv__) + vereq(E.__rfloordiv__, C.__rfloordiv__) - vereq(E() / 1, "C.__div__") - vereq(1 / E(), "C.__rdiv__") - vereq(E() / C(), "C.__div__") - vereq(C() / E(), "C.__div__") # This one would fail + vereq(E() // 1, "C.__floordiv__") + vereq(1 // E(), "C.__rfloordiv__") + vereq(E() // C(), "C.__floordiv__") + vereq(C() // E(), "C.__floordiv__") # This one would fail def dict_type_with_metaclass(): if verbose: |