From e6b72ed3c376a5a3011efc97e62d031eef9c0533 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Fri, 13 Dec 2024 01:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=96=B0=E5=A2=9E=20Pytest=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=80=E5=8F=91=E4=BE=9D=E8=B5=96=E9=A1=B9=E5=B9=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=9F=BA=E5=87=86=E6=B5=8B=E8=AF=95=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run-pytest.yml | 46 ++++++++++++++++++++++++++++++++ pyproject.toml | 8 ++++-- tests/test_none.py | 7 +++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/run-pytest.yml create mode 100644 tests/test_none.py diff --git a/.github/workflows/run-pytest.yml b/.github/workflows/run-pytest.yml new file mode 100644 index 00000000..2c9b2009 --- /dev/null +++ b/.github/workflows/run-pytest.yml @@ -0,0 +1,46 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Pytest API Testing + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + Pytes-API-Testing: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pdm + pdm install + + - name: Test with pytest + run: | + pdm run pytest --junitxml=report/report.xml + + - name: Archive Pytest test report + uses: actions/upload-artifact@v3 + with: + name: SuperTest-test-report + path: report + + - name: Upload Pytest report to GitHub + uses: actions/upload-artifact@v3 + with: + name: Pytest-test-report + path: report \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index acb9b864..72851cc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,8 +41,12 @@ tag_regex = '^v(?:\D*)?(?P([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9 [tool.pdm.build] includes = [] -[tool.pdm.dev-dependencies] -dev = ["nb-cli>=1.4.2"] [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" + +[dependency-groups] +dev = [ + "nb-cli>=1.4.2", + "pytest>=8.3.4", +] diff --git a/tests/test_none.py b/tests/test_none.py new file mode 100644 index 00000000..77cf8e04 --- /dev/null +++ b/tests/test_none.py @@ -0,0 +1,7 @@ +import logging + +def test_none(): + """基准测试示例 + """ + logging.info("测试成功") + pass \ No newline at end of file