musicube/test/conftest.py

31 lines
662 B
Python

import sys
from pathlib import Path
from unittest.mock import Mock
import pytest
from pytest_mock import MockerFixture
# Add source to PATH such that imports within src modules are properly resolved.
SRC_PATH = str(Path(__file__).parent / '..' / 'src')
sys.path.insert(0, SRC_PATH)
from bot import Music
@pytest.fixture
def bot(mocker: MockerFixture):
bot_mock = mocker.patch('discord.ext.commands.Bot', autospec=True)
bot_mock.loop = Mock()
yield bot_mock
@pytest.fixture
def mbot(bot):
mbot_mock = Music(bot)
yield mbot_mock
@pytest.fixture
def ctx(mocker: MockerFixture):
yield mocker.patch('discord.ext.commands.Context', autospec=True)