[Python-checkins] bpo-45010: Remove support of special method __div__ in unittest.mock (GH-27965)

ambv webhook-mailer at python.org
Thu Aug 26 14:19:51 EDT 2021


https://github.com/python/cpython/commit/f9cd40f5e242d3c64cc20a5064500f5fe864f91f
commit: f9cd40f5e242d3c64cc20a5064500f5fe864f91f
branch: main
author: Serhiy Storchaka <storchaka at gmail.com>
committer: ambv <lukasz at langa.pl>
date: 2021-08-26T20:19:47+02:00
summary:

bpo-45010: Remove support of special method __div__ in unittest.mock (GH-27965)

files:
A Misc/NEWS.d/next/Library/2021-08-26-09-54-14.bpo-45010.Cn23bQ.rst
M Doc/library/unittest.mock.rst
M Lib/unittest/mock.py

diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 2f82fded9943d..0856c3fbded08 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -2020,7 +2020,7 @@ The full list of supported magic methods is:
 * Context manager: ``__enter__``, ``__exit__``, ``__aenter__`` and ``__aexit__``
 * Unary numeric methods: ``__neg__``, ``__pos__`` and ``__invert__``
 * The numeric methods (including right hand and in-place variants):
-  ``__add__``, ``__sub__``, ``__mul__``, ``__matmul__``, ``__div__``, ``__truediv__``,
+  ``__add__``, ``__sub__``, ``__mul__``, ``__matmul__``, ``__truediv__``,
   ``__floordiv__``, ``__mod__``, ``__divmod__``, ``__lshift__``,
   ``__rshift__``, ``__and__``, ``__xor__``, ``__or__``, and ``__pow__``
 * Numeric conversion methods: ``__complex__``, ``__int__``, ``__float__``
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index ecf84d224fce3..8193efc7cf125 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1929,7 +1929,7 @@ def _patch_stopall():
 )
 
 numerics = (
-    "add sub mul matmul div floordiv mod lshift rshift and xor or pow truediv"
+    "add sub mul matmul truediv floordiv mod lshift rshift and xor or pow"
 )
 inplace = ' '.join('i%s' % n for n in numerics.split())
 right = ' '.join('r%s' % n for n in numerics.split())
diff --git a/Misc/NEWS.d/next/Library/2021-08-26-09-54-14.bpo-45010.Cn23bQ.rst b/Misc/NEWS.d/next/Library/2021-08-26-09-54-14.bpo-45010.Cn23bQ.rst
new file mode 100644
index 0000000000000..bdf1bfe1ffe06
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-08-26-09-54-14.bpo-45010.Cn23bQ.rst
@@ -0,0 +1,2 @@
+Remove support of special method ``__div__`` in :mod:`unittest.mock`. It is
+not used in Python 3.



More information about the Python-checkins mailing list