From 3d0ad1a552769a1cb6de68e3c0069ea841bc3a98 Mon Sep 17 00:00:00 2001 From: Charles Coggins Date: Wed, 6 Dec 2023 00:47:54 -0600 Subject: [PATCH] Provide whitelist parity for `MagicMock` and `Mock` (#342) * Provide whitelist parity for `MagicMock` and `Mock` There are whitelist entries for the `return_value` and `side_effect` attributes of the `unittest.mock.Mock` class. This change seeks to provide parity for the `unittest.mock.MagicMock` class, which is just a subclass of `Mock` but with default implementations of most of the magic methods. Standard library reference: https://docs.python.org/3/library/unittest.mock.html#magic-mock --- CHANGELOG.md | 4 ++-- vulture/whitelists/unittest_whitelist.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc359d9..d9ec6de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # next (unreleased) -* Bump flake8, flake8-comprehensions and flake8-bugbear. (Sebastian Csar, -#341). +* Bump flake8, flake8-comprehensions and flake8-bugbear (Sebastian Csar, #341). * Switch to tomllib/tomli to support heterogeneous arrays (Sebastian Csar, #340). +* Provide whitelist parity for `MagicMock` and `Mock` (maxrake). # 2.10 (2023-10-06) diff --git a/vulture/whitelists/unittest_whitelist.py b/vulture/whitelists/unittest_whitelist.py index 4df8f6e8..d68e0b55 100644 --- a/vulture/whitelists/unittest_whitelist.py +++ b/vulture/whitelists/unittest_whitelist.py @@ -14,3 +14,6 @@ mock.Mock.return_value mock.Mock.side_effect + +mock.MagicMock.return_value +mock.MagicMock.side_effect