From d7927f286635ccbe7ccb23ed8b4607950f64c8e9 Mon Sep 17 00:00:00 2001 From: ssttkkl Date: Sun, 20 Oct 2024 00:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/python-build.yml | 33 ++++++++++++++++++++++++++++++ src/tests/__init__.py | 10 +++++++++ src/tests/test_load.py | 7 +++++++ 3 files changed, 50 insertions(+) create mode 100644 .github/workflows/python-build.yml create mode 100644 src/tests/__init__.py create mode 100644 src/tests/test_load.py diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml new file mode 100644 index 0000000..2a738a1 --- /dev/null +++ b/.github/workflows/python-build.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: PR Check + +on: + pull_request: + +jobs: + test-api-only: + + strategy: + fail-fast: false + matrix: + os: [ macos-latest, windows-latest, ubuntu-latest ] + python-version: ["3.9", "3.10", "3.11", "3.12"] + pydantic: ["pydantic>=2.0.0", "pydantic<2.0.0"] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install requirements + run: | + pip install poetry + poetry export --with=dev --without-hashes -o requirements.txt + pip install -r requirements.txt + pip install "${{ matrix.pydantic }}" + - name: Test with pytest + run: pytest \ No newline at end of file diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..c0f94ba --- /dev/null +++ b/src/tests/__init__.py @@ -0,0 +1,10 @@ +import pytest + + +class MyTest: + @pytest.fixture(autouse=True) + def load_pixivbot(self, nonebug_init): + import nonebot # 这里的导入必须在函数内 + + # 加载插件 + return nonebot.load_plugins("nonebot_plugin_mahjong_scoreboard") diff --git a/src/tests/test_load.py b/src/tests/test_load.py new file mode 100644 index 0000000..1395221 --- /dev/null +++ b/src/tests/test_load.py @@ -0,0 +1,7 @@ +import pytest +from nonebug import App + + +@pytest.mark.asyncio +async def test_load(app: App): + pass