mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3] Make pytest fixtures available as a plugin (#1858)
* Move all fixtures to pytest plugin folder * Add core dunder all * Update other dunder all's * Black reformat
This commit is contained in:
51
redbot/pytest/rpc.py
Normal file
51
redbot/pytest/rpc.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import pytest
|
||||
from redbot.core.rpc import RPC, RPCMixin
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
__all__ = ["rpc", "rpcmixin", "cog", "existing_func", "existing_multi_func"]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def rpc():
|
||||
return RPC()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def rpcmixin():
|
||||
r = RPCMixin()
|
||||
r.rpc = MagicMock(spec=RPC)
|
||||
return r
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def cog():
|
||||
class Cog:
|
||||
async def cofunc(*args, **kwargs):
|
||||
pass
|
||||
|
||||
async def cofunc2(*args, **kwargs):
|
||||
pass
|
||||
|
||||
async def cofunc3(*args, **kwargs):
|
||||
pass
|
||||
|
||||
def func(*args, **kwargs):
|
||||
pass
|
||||
|
||||
return Cog()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def existing_func(rpc, cog):
|
||||
rpc.add_method(cog.cofunc)
|
||||
|
||||
return cog.cofunc
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def existing_multi_func(rpc, cog):
|
||||
funcs = [cog.cofunc, cog.cofunc2, cog.cofunc3]
|
||||
rpc.add_multi_method(*funcs)
|
||||
|
||||
return funcs
|
||||
Reference in New Issue
Block a user