fixed start after move
This commit is contained in:
@@ -1,34 +1,24 @@
|
||||
import tracemalloc
|
||||
|
||||
tracemalloc.start()
|
||||
|
||||
import pytest
|
||||
from disnake.ext.commands.common_bot_base import CommonBotBase
|
||||
from mock import mock
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from bot.lib.CogsPrep import cog_list, work_with_cogs
|
||||
from integral_lib.CogsPrep import cog_list, work_with_cogs
|
||||
|
||||
|
||||
def test_cog_list():
|
||||
with mock.patch('bot.lib.CogsPrep.listdir') as MockClass:
|
||||
with mock.patch('integral_lib.CogsPrep.listdir') as MockClass:
|
||||
MockClass.return_value = ['cog1.py', 'cog2.py']
|
||||
result = cog_list()
|
||||
assert result == ['cog1', 'cog2']
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("cog", ["cog1.py", "cog2"])
|
||||
@pytest.mark.parametrize("what_do", ['load', 'unload', 'reload', 'disable', 'enable'])
|
||||
async def test_work_with_cogs(what_do, cog):
|
||||
with mock.patch('bot.lib.CogsPrep.rename') as mock_rename:
|
||||
def test_work_with_cogs(what_do, cog):
|
||||
with mock.patch('integral_lib.CogsPrep.rename') as mock_rename:
|
||||
mock_rename.return_value = None
|
||||
mock_bot = mock.MagicMock(spec=CommonBotBase)
|
||||
result = await work_with_cogs(what_do, mock_bot, cog)
|
||||
result = work_with_cogs(what_do, mock_bot, cog)
|
||||
if what_do in ['load', 'enable']:
|
||||
assert mock_bot.load_extension.called
|
||||
elif what_do in ['unload', 'disable']:
|
||||
@@ -36,10 +26,3 @@ async def test_work_with_cogs(what_do, cog):
|
||||
elif what_do == 'reload':
|
||||
assert mock_bot.reload_extension.called
|
||||
|
||||
|
||||
snapshot = tracemalloc.take_snapshot()
|
||||
top_stats = snapshot.statistics('lineno')
|
||||
|
||||
print("[ Top 10 ]")
|
||||
for stat in top_stats[:10]:
|
||||
print(stat)
|
||||
|
||||
Reference in New Issue
Block a user