Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/unittest.mock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ The full list of supported magic methods is:

* ``__hash__``, ``__sizeof__``, ``__repr__`` and ``__str__``
* ``__dir__``, ``__format__`` and ``__subclasses__``
* ``__floor__``, ``__trunc__`` and ``__ceil__``
* ``__round__``, ``__floor__``, ``__trunc__`` and ``__ceil__``
* Comparisons: ``__lt__``, ``__gt__``, ``__le__``, ``__ge__``,
``__eq__`` and ``__ne__``
* Container methods: ``__getitem__``, ``__setitem__``, ``__delitem__``,
Expand Down
2 changes: 1 addition & 1 deletion Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ def _patch_stopall():
# because there is no idivmod
"divmod rdivmod neg pos abs invert "
"complex int float index "
"trunc floor ceil "
"round trunc floor ceil "
"bool next "
)

Expand Down
5 changes: 5 additions & 0 deletions Lib/unittest/test/testmock/testmagicmethods.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import unittest
import sys
from unittest.mock import Mock, MagicMock, _magics
Expand Down Expand Up @@ -280,6 +281,10 @@ def test_magicmock_defaults(self):
self.assertEqual(hash(mock), object.__hash__(mock))
self.assertEqual(str(mock), object.__str__(mock))
self.assertTrue(bool(mock))
self.assertEqual(round(mock), mock.__round__())
self.assertEqual(math.trunc(mock), mock.__trunc__())
self.assertEqual(math.floor(mock), mock.__floor__())
self.assertEqual(math.ceil(mock), mock.__ceil__())

# in Python 3 oct and hex use __index__
# so these tests are for __index__ in py3k
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:class:`unittest.mock.MagicMock` now supports the ``__round__`` magic method.