From 46aa577da843484feb00a99733335754c3ba0649 Mon Sep 17 00:00:00 2001 From: Dmitry Afanasyev Date: Mon, 15 Aug 2022 00:27:16 +0300 Subject: [PATCH] add pytest to sys PATH --- .github/workflows/check-lint.yml | 4 ++-- app/main.py | 4 +--- app/tests/conftest.py | 5 +++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-lint.yml b/.github/workflows/check-lint.yml index ba2aaa8..b4ffbe4 100644 --- a/.github/workflows/check-lint.yml +++ b/.github/workflows/check-lint.yml @@ -34,7 +34,6 @@ jobs: curl -sSL "https://install.python-poetry.org" | python - # Adding `poetry` to `$PATH`: echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Set up cache uses: actions/cache@v3 with: @@ -62,10 +61,11 @@ jobs: #---------------------------------------------- - name: Analysing the code with mypy run: | + source .venv/bin/activate poetry run mypy . - name: Analysing the code with flake8 run: | - poetry run flake8 . + poetry run flake8 app - name: Analysing code with isort run: | poetry run isort --check-only app \ No newline at end of file diff --git a/app/main.py b/app/main.py index bc5103e..9daf975 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,6 @@ from aiogram import Dispatcher from aiogram.utils.executor import start_polling, start_webhook -from core.bot import bot, dispatcher, driver +from core.bot import bot, dispatcher from core.logger import logger from core.scheduler import asyncio_schedule from settings import ( @@ -24,8 +24,6 @@ async def on_shutdown(dp: Dispatcher) -> None: await bot.delete_webhook() # Close DB connection (if used) - if driver: - driver.close() await dp.storage.close() await dp.storage.wait_closed() diff --git a/app/tests/conftest.py b/app/tests/conftest.py index 1f80bf9..9f4f6b2 100644 --- a/app/tests/conftest.py +++ b/app/tests/conftest.py @@ -1,4 +1,6 @@ import asyncio +import sys +from pathlib import Path from typing import Any import aresponses @@ -8,6 +10,9 @@ from aiogram import Bot BOT_ID = 123456789 TOKEN = f'{BOT_ID}:AABBCCDDEEFFaabbccddeeff-1234567890' +# include pytest directory in PATH +sys.path.append(Path(__file__).parent.parent.as_posix()) + class FakeTelegram(aresponses.ResponsesMockServer): def __init__(