aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index e9f0f6f..6b7c3bc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,10 +1,32 @@
1import asyncio 1import asyncio
2import os
3import sys
4import tempfile
2from unittest.mock import AsyncMock, MagicMock 5from unittest.mock import AsyncMock, MagicMock
3import pytest 6import pytest
4 7
5import discord 8import discord
6from discord.ext import commands 9from discord.ext import commands
7 10
11sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
12
13
14@pytest.fixture(autouse=True, scope="function")
15def setup_test_env(monkeypatch):
16 test_db = os.path.join(tempfile.gettempdir(), "test_senator.db")
17 if os.path.exists(test_db):
18 os.remove(test_db)
19 monkeypatch.setenv("SENATOR_DB_PATH", test_db)
20 reload_database()
21 yield
22 if os.path.exists(test_db):
23 os.remove(test_db)
24
25
26def reload_database():
27 import cogs.utils.database as db_module
28 db_module._initialized = False
29
8 30
9class MockUser: 31class MockUser:
10 def __init__(self, id=12345, name="testuser", discriminator="0001"): 32 def __init__(self, id=12345, name="testuser", discriminator="0001"):