mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
bpo-35022: unittest.mock.MagicMock now also supports __fspath__ (GH-9960)
The MagicMock class supports many magic methods, but not __fspath__. To ease testing with modules such as os.path, this function is now supported by default.
This commit is contained in:
parent
1770d1c512
commit
6c83d9f4a7
4 changed files with 18 additions and 0 deletions
|
@ -1713,6 +1713,7 @@ magic_methods = (
|
|||
"complex int float index "
|
||||
"round trunc floor ceil "
|
||||
"bool next "
|
||||
"fspath "
|
||||
)
|
||||
|
||||
numerics = (
|
||||
|
@ -1760,6 +1761,7 @@ _calculate_return_value = {
|
|||
'__hash__': lambda self: object.__hash__(self),
|
||||
'__str__': lambda self: object.__str__(self),
|
||||
'__sizeof__': lambda self: object.__sizeof__(self),
|
||||
'__fspath__': lambda self: f"{type(self).__name__}/{self._extract_mock_name()}/{id(self)}",
|
||||
}
|
||||
|
||||
_return_values = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue