diff options
| author | 2020-11-10 01:42:51 +0200 | |
|---|---|---|
| committer | 2020-11-10 01:42:51 +0200 | |
| commit | 690f906c613ce90da403fc7a8942dc4d24cea000 (patch) | |
| tree | d3dac1ccaef94a1d5499322f1b2862ae3c51cbbf /tests/helpers.py | |
| parent | Automatically add periods as visual buffers (diff) | |
| parent | Merge pull request #1273 from python-discord/sebastiaan/bugs/codeblock-langua... (diff) | |
Merge branch 'master' into pure/feature/infraction-append
Diffstat (limited to '')
| -rw-r--r-- | tests/helpers.py | 21 | 
1 files changed, 2 insertions, 19 deletions
| diff --git a/tests/helpers.py b/tests/helpers.py index e47fdf28f..870f66197 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -5,7 +5,7 @@ import itertools  import logging  import unittest.mock  from asyncio import AbstractEventLoop -from typing import Callable, Iterable, Optional +from typing import Iterable, Optional  import discord  from aiohttp import ClientSession @@ -14,6 +14,7 @@ from discord.ext.commands import Context  from bot.api import APIClient  from bot.async_stats import AsyncStatsClient  from bot.bot import Bot +from tests._autospec import autospec  # noqa: F401 other modules import it via this module  for logger in logging.Logger.manager.loggerDict.values(): @@ -26,24 +27,6 @@ for logger in logging.Logger.manager.loggerDict.values():      logger.setLevel(logging.CRITICAL) -def autospec(target, *attributes: str, **kwargs) -> Callable: -    """Patch multiple `attributes` of a `target` with autospecced mocks and `spec_set` as True.""" -    # Caller's kwargs should take priority and overwrite the defaults. -    kwargs = {'spec_set': True, 'autospec': True, **kwargs} - -    # Import the target if it's a string. -    # This is to support both object and string targets like patch.multiple. -    if type(target) is str: -        target = unittest.mock._importer(target) - -    def decorator(func): -        for attribute in attributes: -            patcher = unittest.mock.patch.object(target, attribute, **kwargs) -            func = patcher(func) -        return func -    return decorator - -  class HashableMixin(discord.mixins.EqualityComparable):      """      Mixin that provides similar hashing and equality functionality as discord.py's `Hashable` mixin. | 
