diff options
author | Max Bélanger <aeromax@gmail.com> | 2018-10-25 14:48:58 -0700 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-25 23:48:58 +0200 |
commit | 6c83d9f4a72905d968418bef670bb3091d2744db (patch) | |
tree | 36e86ffe12d882014bed38909a417a6f713b2e93 /Lib/unittest/mock.py | |
parent | 1770d1c5121ed6c64d7072875738f97e07eede8a (diff) | |
download | cpython-git-6c83d9f4a72905d968418bef670bb3091d2744db.tar.gz |
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.
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 6b7f293bc5..1a6c1a606c 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -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 = { |