diff options
author | 2019-11-14 10:50:49 +0100 | |
---|---|---|
committer | 2019-11-14 10:50:49 +0100 | |
commit | ccda39c5e42e94011c9c1bd14080d004d3d61f02 (patch) | |
tree | 7941fc0bb72a4de5cd8caf344e297252dbd96edb /tests/helpers.py | |
parent | Merging in master (diff) |
Add bot=False default value to MockMember
By default, a mocked value is considered `truthy` in Python, like all
non-empty/non-zero/non-None values in Python. This means that if an
attribute is not explicitly set on a mock, it will evaluate at as
truthy in a boolean context, since the mock will provide a truthy
mocked value by default.
This is not the best default value for the `bot` attribute of our
MockMember type, since members are rarely bots. It makes much more
intuitive sense to me to consider a member to not be a bot, unless we
explicitly set `bot=True`.
This commit sets that sensible default value that can be overwritten
by passing `bot=False` to the constructor or setting the `object.bot`
attribute to `False` after the creation of the mock.
Diffstat (limited to 'tests/helpers.py')
-rw-r--r-- | tests/helpers.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index 22f07934f..199d45700 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -242,7 +242,7 @@ class MockMember(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin information, see the `MockGuild` docstring. """ def __init__(self, roles: Optional[Iterable[MockRole]] = None, **kwargs) -> None: - default_kwargs = {'name': 'member', 'id': next(self.discord_id)} + default_kwargs = {'name': 'member', 'id': next(self.discord_id), 'bot': False} super().__init__(spec_set=member_instance, **collections.ChainMap(kwargs, default_kwargs)) self.roles = [MockRole(name="@everyone", position=1, id=0)] |