diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8d5565a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,24 @@ +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = [ + "-v", + "--tb=short", + "--strict-markers", + "--disable-warnings", + "--asyncio-mode=auto" +] +asyncio_default_fixture = "event_loop" +asyncio_default_fixture_loop_scope = "function" +markers = [ + "asyncio: marks tests as async (deselect with '-m \"not asyncio\"')", + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "integration: marks tests as integration tests", + "unit: marks tests as unit tests" +] +filterwarnings = [ + "ignore::DeprecationWarning", + "ignore::PendingDeprecationWarning" +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 6b22b97..0000000 --- a/pytest.ini +++ /dev/null @@ -1,19 +0,0 @@ -[tool:pytest] -testpaths = tests -python_files = test_*.py -python_classes = Test* -python_functions = test_* -addopts = - -v - --tb=short - --strict-markers - --disable-warnings - --asyncio-mode=auto -markers = - asyncio: marks tests as async (deselect with '-m "not asyncio"') - slow: marks tests as slow (deselect with '-m "not slow"') - integration: marks tests as integration tests - unit: marks tests as unit tests -filterwarnings = - ignore::DeprecationWarning - ignore::PendingDeprecationWarning \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index dab99b4..de68333 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,9 @@ from database.db import BotDB # Импортируем моки в самом начале import tests.mocks +# Настройка pytest-asyncio +pytest_plugins = ('pytest_asyncio',) + @pytest.fixture(scope="session") def event_loop(): diff --git a/tests/test_monitor.py b/tests/test_monitor.py index b4d3259..41f39b5 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -2,6 +2,7 @@ """ Тестовый скрипт для проверки модуля мониторинга сервера """ +import pytest import asyncio import sys import os @@ -23,6 +24,7 @@ class MockBot: print(f"{'='*60}\n") +@pytest.mark.asyncio async def test_monitor(): """Тестирование модуля мониторинга""" print("🧪 Тестирование модуля мониторинга сервера")