From d364d2b6443e3cdbfeaf6e06ee8711b417e94916 Mon Sep 17 00:00:00 2001 From: Arisu Tachibana Date: Fri, 28 Feb 2025 12:27:23 +0900 Subject: [PATCH] pyproject: Add testing for different python versions with tox This change is needed for testing difference with python versions used on different distributions. Catching problems for example with f-string format. Ref: https://peps.python.org/pep-0701/ Signed-off-by: Arisu Tachibana --- .github/workflows/poetry.yml | 6 ++++-- pyproject.toml | 1 + scripts/check.sh | 2 +- tox.ini | 11 +++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tox.ini diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index 21b01b3..7bb6008 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -9,6 +9,8 @@ jobs: - uses: actions/checkout@v4 - name: Install Python uses: actions/setup-python@v5 + with: + python-version: '3.11' - name: Install poetry uses: abatilo/actions-poetry@v3 - name: Install shellcheck @@ -28,5 +30,5 @@ jobs: run: poetry run black --check --verbose . - name: Isort check run: poetry run isort . --profile black --check --diff - - name: Pytest check - run: poetry run pytest -rP + - name: Tox check (pytest) + run: poetry run tox diff --git a/pyproject.toml b/pyproject.toml index a6f0aec..9dbd47e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ black = "^24.8.0" isort = "^5.13.2" pytest = "^8.3.3" poethepoet = "^0.29.0" +tox = "^4.24.1" [tool.poe.tasks] check = "./scripts/check.sh" diff --git a/scripts/check.sh b/scripts/check.sh index 81312e7..8e4b756 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -2,4 +2,4 @@ poetry run black . --extend-exclude="kcidev-src" poetry run isort . --extend-skip="kcidev-src" -poetry run pytest -rP --ignore="kcidev-src" +poetry run tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..bcb221e --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +[tox] +env_list = py311,py312 + +[testenv] +allowlist_externals = poetry +commands_pre = + poetry install --no-root + poetry sync +commands = + poetry run pytest tests/ --import-mode importlib +