From f51975632d78913a5da7bd5b3a6d5b97b53080ad Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 10:44:09 +0200 Subject: [PATCH 1/7] Updated github workflows versions to major when possible --- .github/workflows/base.yml | 29 +++++++++++++++++------------ .github/workflows/updater.yml | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 453489e..3ff4536 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -23,10 +23,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 - name: Install python 3.9 - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 @@ -57,7 +57,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 # General case - name: Install python ${{ matrix.nox_session.python }} for tests (not 3.5 not 3.13) @@ -99,7 +99,7 @@ jobs: cache-build: true - name: Install python 3.12 for nox - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 @@ -118,7 +118,7 @@ jobs: # Share ./docs/reports so that they can be deployed with doc in next job - name: Share reports with other jobs if: runner.os == 'Linux' - uses: actions/upload-artifact@v4.3.1 + uses: actions/upload-artifact@v4 with: name: reports_dir path: ./docs/reports @@ -128,10 +128,10 @@ jobs: if: github.event_name == 'pull_request' steps: - name: Checkout - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 - name: Install python 3.9 for nox - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 @@ -153,19 +153,20 @@ jobs: run: echo "$GITHUB_CONTEXT" - name: Checkout with no depth - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 with: fetch-depth: 0 # so that gh-deploy works + # persist-credentials: false # see https://github.com/orgs/community/discussions/25702 - name: Install python 3.9 for nox - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: 3.9 architecture: x64 # 1) retrieve the reports generated previously - name: Retrieve reports - uses: actions/download-artifact@v4.1.4 + uses: actions/download-artifact@v4 with: name: reports_dir path: ./docs/reports @@ -197,7 +198,7 @@ jobs: EOF - name: \[not on TAG\] Publish coverage report if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') - uses: codecov/codecov-action@v4.1.1 + uses: codecov/codecov-action@v4 with: files: ./docs/reports/coverage/coverage.xml - name: \[not on TAG\] Build wheel and sdist @@ -209,7 +210,11 @@ jobs: # 7) Create github release and build the wheel - name: \[TAG only\] Build wheel and create github release if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - run: nox -s release -- ${{ secrets.GITHUB_TOKEN }} + # We would have to use a PAT instead of GITHUB_TOKEN if we want the next job to trigger. + # See https://github.com/orgs/community/discussions/25702 + # For now we will rather rely on a "workflow completed" trigger to avoid + # having a token expiration date to manage + run: nox -s release -- ${{ secrets.GITHUB_TOKEN }} # ${{ secrets.WORKFLOW_SECRET}} # 8) Publish the wheel on PyPi - name: \[TAG only\] Deploy on PyPi diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 7ccec7f..e3a55ee 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -12,13 +12,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: # [Required] Access token with `workflow` scope. token: ${{ secrets.WORKFLOW_SECRET }} - name: Run GitHub Actions Version Updater - uses: saadmk11/github-actions-version-updater@v0.8.1 + uses: saadmk11/github-actions-version-updater@v0.8 with: # [Required] Access token with `workflow` scope. token: ${{ secrets.WORKFLOW_SECRET }} From 4d031fe7a01930d6a7a13d8f46226dce014690bd Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 10:46:55 +0200 Subject: [PATCH 2/7] Added support for python 3.14 and added a proper github pages workflow (explicit). Fixed #79 --- .github/workflows/base.yml | 8 ++--- .github/workflows/ghpages.yml | 53 ++++++++++++++++++++++++++++ ci_tools/nox_utils.py | 29 +++------------ noxfile.py | 66 +++++++++++++++++------------------ setup.cfg | 1 + 5 files changed, 95 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/ghpages.yml diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 3ff4536..43aa50c 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -60,8 +60,8 @@ jobs: uses: actions/checkout@v4 # General case - - name: Install python ${{ matrix.nox_session.python }} for tests (not 3.5 not 3.13) - if: ${{ ! contains(fromJson('["3.5", "3.13"]'), matrix.nox_session.python ) }} + - name: Install python ${{ matrix.nox_session.python }} for tests (not 3.5 not 3.14) + if: ${{ ! contains(fromJson('["3.5", "3.14"]'), matrix.nox_session.python ) }} uses: MatteoH2O1999/setup-python@v4 # actions/setup-python@v5.0.0 id: set-py with: @@ -86,8 +86,8 @@ jobs: PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org" - - name: Install python ${{ matrix.nox_session.python }} for tests (3.13) - if: contains(fromJson('["3.13"]'), matrix.nox_session.python ) + - name: Install python ${{ matrix.nox_session.python }} for tests (3.14) + if: contains(fromJson('["3.14"]'), matrix.nox_session.python ) uses: actions/setup-python@v5 id: set-py-latest with: diff --git a/.github/workflows/ghpages.yml b/.github/workflows/ghpages.yml new file mode 100644 index 0000000..909c2a2 --- /dev/null +++ b/.github/workflows/ghpages.yml @@ -0,0 +1,53 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy Static Website from gh-pages branch + +on: + # Runs on pushes targeting the default branch + push: + branches: ["gh-pages"] + + # Since the pushes made by the workflow using GITHUB_TOKEN do not trigger the above, + # Add an explicit trigger for workflow completion + workflow_run: + workflows: ['Build'] + types: [completed] + branches: + - 'main' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: gh-pages + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: '.' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/ci_tools/nox_utils.py b/ci_tools/nox_utils.py index 153db35..74a9b15 100644 --- a/ci_tools/nox_utils.py +++ b/ci_tools/nox_utils.py @@ -3,7 +3,6 @@ from pathlib import Path import shutil import os -import re from typing import Sequence, Dict, Union @@ -13,8 +12,9 @@ nox_logger = logging.getLogger("nox") -PY27, PY35, PY36, PY37, PY38, PY39, PY310, PY311, PY312, PY313 = ("2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", - "3.11", "3.12", "3.13") +PY27, PY35, PY36, PY37, PY38, PY39, PY310, PY311, PY312, PY313, PY314 = ( + "2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" +) DONT_INSTALL = "dont_install" @@ -104,28 +104,7 @@ def install_any(session, # use the provided versions dictionary to update the versions if versions_dct is None: versions_dct = dict() - - _pkgs = pkgs - pkgs = [] - for pkg in _pkgs: - # Find version specifiers if any - try: - separator = next(re.finditer(r"[>=<~!]", pkg)).start() - p_name, p_version = pkg[:separator], pkg[separator:] - except StopIteration: - p_name, p_version = pkg, "" - - # Is there something to override them in our versions_dct ? - specifier_override = versions_dct.get(p_name, "") - if specifier_override == DONT_INSTALL: - print(f"NOT INSTALLING {p_name}{p_version} as described in the nox parametrization grid") - continue - if specifier_override: - print(f"OVERRIDING {p_name}{p_version} to {p_name}{specifier_override} as described in the nox parametrization grid") - p_version = specifier_override - - # Store the definitive package name and version specifier - pkgs.append(f"{p_name}{p_version}") + pkgs = [pkg + versions_dct.get(pkg, "") for pkg in pkgs if versions_dct.get(pkg, "") != DONT_INSTALL] nox_logger.debug("\nAbout to install *%s* requirements: %s.\n " "Conda pkgs are %s" % (phase_name, pkgs, use_conda_for)) diff --git a/noxfile.py b/noxfile.py index c7ca853..68e24b4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,3 @@ -import argparse -import json import logging import nox # noqa @@ -9,7 +7,8 @@ # add parent folder to python path so that we can import noxfile_utils.py # note that you need to "pip install -r noxfile-requiterements.txt" for this file to work. sys.path.append(str(Path(__file__).parent / "ci_tools")) -from nox_utils import (PY27, PY37, PY36, PY35, PY38, PY39, PY310, PY311, PY312, PY313, install_reqs, rm_folder, rm_file, +from nox_utils import (PY27, PY37, PY36, PY35, PY38, PY39, PY310, PY311, PY312, PY313, PY314, install_reqs, rm_folder, + rm_file, DONT_INSTALL) # noqa @@ -54,6 +53,8 @@ class Folders: ENVS = { + # python 3.14 + (PY314, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.13 (PY313, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.12 @@ -180,8 +181,7 @@ def tests(session, coverage, pkg_specs): "-m", "pytest", f"--junitxml={Folders.test_xml}", f"--html={Folders.test_html}", "-v", "tests/") - - # session.run2("coverage report") # this shows in terminal + fails under XX%, same as --cov-report term --cov-fail-under=70 # noqa + session.run("coverage", "report") # this shows in terminal + fails under XX%, same as --cov-report term --cov-fail-under=70 # noqa session.run("coverage", "xml", "-o", f"{Folders.coverage_xml}") session.run("coverage", "html", "-d", f"{Folders.coverage_reports}") # delete this intermediate file, it is not needed anymore @@ -334,34 +334,34 @@ def release(session): "-d", f"https://{gh_org}.github.io/{gh_repo}/changelog", current_tag) -@nox.session(python=False) -def gha_list(session): - """(mandatory arg: ) Prints all sessions available for , for GithubActions.""" - - # see https://stackoverflow.com/q/66747359/7262247 - - # The options - parser = argparse.ArgumentParser() - parser.add_argument("-s", "--session", help="The nox base session name") - parser.add_argument( - "-v", - "--with_version", - action="store_true", - default=False, - help="Return a list of lists where the first element is the python version and the second the nox session.", - ) - additional_args = parser.parse_args(session.posargs) - - # Now use --json CLI option - out = session.run("nox", "-l", "--json", "-s", "tests", external=True, silent=True) - sessions_list = [{"python": s["python"], "session": s["session"]} for s in json.loads(out)] - - # TODO filter ? - - # print the list so that it can be caught by GHA. - # Note that json.dumps is optional since this is a list of string. - # However it is to remind us that GHA expects a well-formatted json list of strings. - print(json.dumps(sessions_list)) +# @nox.session(python=False) +# def gha_list(session): +# """(mandatory arg: ) Prints all sessions available for , for GithubActions.""" +# +# # see https://stackoverflow.com/q/66747359/7262247 +# +# # The options +# parser = argparse.ArgumentParser() +# parser.add_argument("-s", "--session", help="The nox base session name") +# parser.add_argument( +# "-v", +# "--with_version", +# action="store_true", +# default=False, +# help="Return a list of lists where the first element is the python version and the second the nox session.", +# ) +# additional_args = parser.parse_args(session.posargs) +# +# # Now use --json CLI option +# out = session.run("nox", "-l", "--json", "-s", "tests", external=True, silent=True) +# sessions_list = [{"python": s["python"], "session": s["session"]} for s in json.loads(out)] +# +# # TODO filter ? +# +# # print the list so that it can be caught by GHA. +# # Note that json.dumps is optional since this is a list of string. +# # However it is to remind us that GHA expects a well-formatted json list of strings. +# print(json.dumps(sessions_list)) # if __name__ == '__main__': diff --git a/setup.cfg b/setup.cfg index 93354cd..db8aac1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,6 +31,7 @@ classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.14 Framework :: Pytest [options] From 72de71d493148e3feeb09c9764551731f6db9e21 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 10:47:57 +0200 Subject: [PATCH 3/7] changelog updated --- docs/changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index a9a1aa1..ceae87f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ # Changelog +### 1.10.7 - python 3.14 and pytest 8.4.0 (in progress) + +- Added support for python 3.14 and added a proper github pages workflow (explicit). Fixed + [#79](https://github.com/smarie/python-pytest-harvest/issues/79) + ### 1.10.6 - bugfixes and maintenance chores - Refactored layout and CI. Fixed [#56](https://github.com/smarie/python-pytest-harvest/issues/56). From d151c816f7e54a9097e23a2536d9fd8a4f7e8409 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 12:57:09 +0200 Subject: [PATCH 4/7] Dropped support for python <3.9 and added a proper github pages workflow (explicit). Fixed #79 --- README.md | 2 +- docs/changelog.md | 4 ++-- docs/index.md | 2 +- noxfile.py | 34 +++------------------------------- setup.cfg | 9 +-------- 5 files changed, 8 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 88bad64..0b40304 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ *Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.* -[![Python versions](https://img.shields.io/pypi/pyversions/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) [![Build Status](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml/badge.svg)](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml) [![Tests Status](https://smarie.github.io/python-pytest-harvest/reports/junit/junit-badge.svg?dummy=8484744)](https://smarie.github.io/python-pytest-harvest/reports/junit/report.html) [![codecov](https://codecov.io/gh/smarie/python-pytest-harvest/branch/master/graph/badge.svg)](https://codecov.io/gh/smarie/python-pytest-harvest) +[![Python versions](https://img.shields.io/pypi/pyversions/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) ![Pytest versions](https://img.shields.io/badge/pytest-6%20%7C%207%20%7C%208-blue) [![Build Status](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml/badge.svg)](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml) [![Tests Status](https://smarie.github.io/python-pytest-harvest/reports/junit/junit-badge.svg?dummy=8484744)](https://smarie.github.io/python-pytest-harvest/reports/junit/report.html) [![codecov](https://codecov.io/gh/smarie/python-pytest-harvest/branch/master/graph/badge.svg)](https://codecov.io/gh/smarie/python-pytest-harvest) [![Documentation](https://img.shields.io/badge/doc-latest-blue.svg)](https://smarie.github.io/python-pytest-harvest/) [![PyPI](https://img.shields.io/pypi/v/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) [![Downloads](https://pepy.tech/badge/pytest-harvest)](https://pepy.tech/project/pytest-harvest) [![Downloads per week](https://pepy.tech/badge/pytest-harvest/week)](https://pepy.tech/project/pytest-harvest) [![GitHub stars](https://img.shields.io/github/stars/smarie/python-pytest-harvest.svg)](https://github.com/smarie/python-pytest-harvest/stargazers) diff --git a/docs/changelog.md b/docs/changelog.md index ceae87f..6555c6e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,8 +1,8 @@ # Changelog -### 1.10.7 - python 3.14 and pytest 8.4.0 (in progress) +### 1.11.0 - dropped support for python < 3.9 and fixed - pytest 8.4.0 (in progress) -- Added support for python 3.14 and added a proper github pages workflow (explicit). Fixed +- Dropped support for python <3.9 and added a proper github pages workflow (explicit). Fixed [#79](https://github.com/smarie/python-pytest-harvest/issues/79) ### 1.10.6 - bugfixes and maintenance chores diff --git a/docs/index.md b/docs/index.md index f57db52..51c8956 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ *Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.* -[![Python versions](https://img.shields.io/pypi/pyversions/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) [![Build Status](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml/badge.svg)](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml) [![Tests Status](https://smarie.github.io/python-pytest-harvest/reports/junit/junit-badge.svg?dummy=8484744)](https://smarie.github.io/python-pytest-harvest/reports/junit/report.html) [![codecov](https://codecov.io/gh/smarie/python-pytest-harvest/branch/master/graph/badge.svg)](https://codecov.io/gh/smarie/python-pytest-harvest) +[![Python versions](https://img.shields.io/pypi/pyversions/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) ![Pytest versions](https://img.shields.io/badge/pytest-6%20%7C%207%20%7C%208-blue) [![Build Status](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml/badge.svg)](https://github.com/smarie/python-pytest-harvest/actions/workflows/base.yml) [![Tests Status](https://smarie.github.io/python-pytest-harvest/reports/junit/junit-badge.svg?dummy=8484744)](https://smarie.github.io/python-pytest-harvest/reports/junit/report.html) [![codecov](https://codecov.io/gh/smarie/python-pytest-harvest/branch/master/graph/badge.svg)](https://codecov.io/gh/smarie/python-pytest-harvest) [![Documentation](https://img.shields.io/badge/doc-latest-blue.svg)](https://smarie.github.io/python-pytest-harvest/) [![PyPI](https://img.shields.io/pypi/v/pytest-harvest.svg)](https://pypi.python.org/pypi/pytest-harvest/) [![Downloads](https://pepy.tech/badge/pytest-harvest)](https://pepy.tech/project/pytest-harvest) [![Downloads per week](https://pepy.tech/badge/pytest-harvest/week)](https://pepy.tech/project/pytest-harvest) [![GitHub stars](https://img.shields.io/github/stars/smarie/python-pytest-harvest.svg)](https://github.com/smarie/python-pytest-harvest/stargazers) diff --git a/noxfile.py b/noxfile.py index 68e24b4..43829db 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,9 +7,7 @@ # add parent folder to python path so that we can import noxfile_utils.py # note that you need to "pip install -r noxfile-requiterements.txt" for this file to work. sys.path.append(str(Path(__file__).parent / "ci_tools")) -from nox_utils import (PY27, PY37, PY36, PY35, PY38, PY39, PY310, PY311, PY312, PY313, PY314, install_reqs, rm_folder, - rm_file, - DONT_INSTALL) # noqa +from nox_utils import (PY39, PY310, PY311, PY312, PY313, PY314, install_reqs, rm_folder, rm_file, DONT_INSTALL) # noqa pkg_name = "pytest_harvest" @@ -53,8 +51,8 @@ class Folders: ENVS = { - # python 3.14 - (PY314, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, + # python 3.14 - numpy is not available in precompiled version for this python version yet + # (PY314, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.13 (PY313, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # python 3.12 @@ -68,32 +66,6 @@ class Folders: (PY39, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, (PY39, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}}, (PY39, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, - # python 3.8 - (PY38, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5", "setuptools": "==71.0.0"}}, - (PY38, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "setuptools": "==71.0.0", "pytest-asyncio": DONT_INSTALL}}, - (PY38, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7"}}, - (PY38, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8"}}, - (PY38, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, - # python 2.7 - (PY27, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<4", "pytest-cases": "<3.7", "pytest-asyncio": DONT_INSTALL}}, - (PY27, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<5", "pytest-cases": "<3.7", "pytest-asyncio": DONT_INSTALL}}, - # python 3.5 - (PY35, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<4", "pytest-cases": "<3.7", "pytest-asyncio": DONT_INSTALL}}, - (PY35, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<5", "pytest-cases": "<3.7", "pytest-asyncio": DONT_INSTALL}}, - (PY35, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">10", "pytest": "<6", "pytest-cases": "<3.7"}}, - # python 3.6 - (PY36, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<4", "pytest-cases": "<3.7"}}, - (PY36, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5", "pytest-cases": "<3.7"}}, - (PY36, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-cases": "<3.7"}}, - (PY36, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7", "pytest-cases": "<3.7"}}, - (PY36, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "", "pytest-cases": "<3.7"}}, - # python 3.7 - (PY37, "pytest3.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<4", "pytest-cases": "<3.7"}}, - (PY37, "pytest4.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<5", "pytest-cases": "<3.7"}}, - (PY37, "pytest5.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<6", "pytest-cases": "<3.7", "pytest-asyncio": DONT_INSTALL}}, - (PY37, "pytest6.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<7", "pytest-cases": "<3.7"}}, - (PY37, "pytest7.x"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": "<8", "pytest-cases": "<3.7"}}, - # (PY37, "pytest-latest"): {"coverage": False, "pkg_specs": {"pip": ">19", "pytest": ""}}, # IMPORTANT: this should be last so that the folder docs/reports is not deleted afterwards (PY311, "pytest-latest"): {"coverage": True, "pkg_specs": {"pip": ">19", "pytest": ""}}, } diff --git a/setup.cfg b/setup.cfg index db8aac1..6fd7fed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,22 +42,15 @@ install_requires = packaging decopatch makefun>=1.5 - # note: pytest, too :) - # note: do not use double quotes in these, this triggers a weird bug in PyCharm in debug mode only - funcsigs;python_version<'3.3' # TODO remove and use common_mini_six.py six - pathlib2;python_version<'3.2' + tests_require = pytest numpy pandas tabulate pytest-cases>=2.3.0 - # for some reason these pytest dependencies were not declared in old versions of pytest - six;python_version<'3.6' - attr;python_version<'3.6' - pluggy;python_version<'3.6' # test_suite = tests --> no need apparently # From 46600f334ae929fd7722ac2440b84e7ef3501882 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 13:06:46 +0200 Subject: [PATCH 5/7] Removed six from dependencies and simplified a few things --- setup.py | 18 +----------------- src/pytest_harvest/__init__.py | 4 ++-- src/pytest_harvest/common.py | 23 ----------------------- src/pytest_harvest/fixture_cache.py | 23 +++++++---------------- src/pytest_harvest/plugin.py | 20 ++++++-------------- src/pytest_harvest/results_bags.py | 16 ++++------------ src/pytest_harvest/results_session.py | 5 ++--- tests/test_all_raw_with_meta_check.py | 2 +- 8 files changed, 23 insertions(+), 88 deletions(-) diff --git a/setup.py b/setup.py index acec745..d32be14 100644 --- a/setup.py +++ b/setup.py @@ -33,23 +33,7 @@ args = { "write_to": "src/pytest_harvest/_version.py", } -# Use the 'version_file_template' directive if possible to avoid type hints and annotations (python <3.8) -setuptools_scm_version = pkg_resources.get_distribution("setuptools_scm").version -# for some reason importing packaging.version.Version here fails on python 3.5 -# from packaging.version import Version -# if Version(setuptools_scm_version) >= Version('6'): -setuptools_scm_version_major = int(setuptools_scm_version.split(".")[0]) -if setuptools_scm_version_major >= 6: - # template_arg_name = "version_file_template" if Version(setuptools_scm_version) >= Version('8.1') else "write_to_template" - # print(Version(setuptools_scm_version)) - # print(template_arg_name) - - # Note that it was named 'write_to_template' earlier. But at that time it was not generating annotations so no need. - args["write_to_template"] = """# file generated by setuptools_scm and customized -# don't change, don't track in version control -__version__ = version = '{version}' -__version_tuple__ = version_tuple = {version_tuple} -""" + # (3) Call setup() with as little args as possible setup( download_url=DOWNLOAD_URL, diff --git a/src/pytest_harvest/__init__.py b/src/pytest_harvest/__init__.py index f86f10c..825a37d 100644 --- a/src/pytest_harvest/__init__.py +++ b/src/pytest_harvest/__init__.py @@ -17,8 +17,8 @@ # -- Source mode -- # use setuptools_scm to get the current version from src using git from setuptools_scm import get_version as _gv - from os import path as _path - __version__ = _gv(_path.join(_path.dirname(__file__), _path.pardir)) + from pathlib import Path as _Path + __version__ = _gv(_Path(__file__).parent.parent.parent) __all__ = [ '__version__', diff --git a/src/pytest_harvest/common.py b/src/pytest_harvest/common.py index 80128ee..f1828bc 100644 --- a/src/pytest_harvest/common.py +++ b/src/pytest_harvest/common.py @@ -4,29 +4,6 @@ HARVEST_PREFIX = "harvest_rep_" -# def get_fixture_name(fixture_fun): -# """ -# Internal utility to retrieve the fixture name corresponding to the given fixture function . -# Indeed there is currently no pytest API to do this. -# -# :param fixture_fun: -# :return: -# """ -# custom_fixture_name = getattr(fixture_fun._pytestfixturefunction, 'name', None) -# -# if custom_fixture_name is not None: -# # there is a custom fixture name -# return custom_fixture_name -# else: -# obj__name = getattr(fixture_fun, '__name__', None) -# if obj__name is not None: -# # a function, probably -# return obj__name -# else: -# # a callable object probably -# return str(fixture_fun) - - def get_fixture_value(request, fixture_name): """ Returns the value associated with fixture named `fixture_name`, in provided `request` context. diff --git a/src/pytest_harvest/fixture_cache.py b/src/pytest_harvest/fixture_cache.py index f83cc10..0d99b7e 100644 --- a/src/pytest_harvest/fixture_cache.py +++ b/src/pytest_harvest/fixture_cache.py @@ -3,26 +3,17 @@ from decopatch import DECORATED, function_decorator from makefun import wraps, add_signature_parameters -from six import string_types from pytest_harvest.common import get_scope - -try: # python 3+ - from typing import Union, Any, Dict, Callable -except ImportError: - pass - -try: # python 3.3+ - from inspect import signature, Parameter -except ImportError: - from funcsigs import signature, Parameter +from typing import Union, Any, Dict, Callable +from inspect import signature, Parameter @function_decorator -def saved_fixture(store='fixture_store', # type: Union[str, Dict[str, Any]] - key=None, # type: str - views=None, # type: Dict[str, Callable[[Any], Any]] - save_raw=None, # type: bool +def saved_fixture(store: Union[str, Dict[str, Any]] = 'fixture_store', + key: str = None, + views: Dict[str, Callable[[Any], Any]] = None, + save_raw: bool = None, fixture_fun=DECORATED ): """ @@ -81,7 +72,7 @@ def test_synthesis(fixture_store): key = key or fixture_name # is the store a fixture or an object ? - store_is_a_fixture = isinstance(store, string_types) + store_is_a_fixture = isinstance(store, str) # if the store object is already available, we can ensure that it is initialized. Otherwise trust pytest for that if not store_is_a_fixture: diff --git a/src/pytest_harvest/plugin.py b/src/pytest_harvest/plugin.py index c289d67..e08793e 100644 --- a/src/pytest_harvest/plugin.py +++ b/src/pytest_harvest/plugin.py @@ -3,17 +3,9 @@ from logging import warning from shutil import rmtree import pytest -import six -try: - from pathlib import Path -except ImportError: - from pathlib2 import Path # python 2 - -try: # python 3.5+ - from typing import Union, Iterable, Mapping, Any -except ImportError: - pass +from pathlib import Path +from typing import Union, Iterable, Mapping, Any from pytest_harvest.common import HARVEST_PREFIX from pytest_harvest.results_bags import create_results_bag_fixture @@ -239,8 +231,8 @@ def get_session_results_df(session_or_request, try: import pandas as pd # pylint: disable=import-outside-toplevel except ImportError as e: - six.raise_from(Exception("There was an error importing `pandas` module. Fixture `session_results_df` and method" - "`get_session_results_df` can not be used in this session."), e) + raise Exception("There was an error importing `pandas` module. Fixture `session_results_df` and method" + "`get_session_results_df` can not be used in this session.") from e # in case of xdist, make sure persisted workers results have been reloaded possibly_restore_xdist_workers_structs(session_or_request) @@ -309,9 +301,9 @@ def get_filtered_results_df(session, try: import pandas as pd # pylint: disable=import-outside-toplevel except ImportError as e: - six.raise_from(Exception("There was an error importing `pandas` module. Fixture `session_results_df` and " + raise Exception("There was an error importing `pandas` module. Fixture `session_results_df` and " "methods `get_filtered_results_df` and `get_module_results_df` can not be used in this" - " session. "), e) + " session. ") from e # in case of xdist, make sure persisted workers results have been reloaded possibly_restore_xdist_workers_structs(session) diff --git a/src/pytest_harvest/results_bags.py b/src/pytest_harvest/results_bags.py index d0333db..80d9f1b 100644 --- a/src/pytest_harvest/results_bags.py +++ b/src/pytest_harvest/results_bags.py @@ -1,12 +1,4 @@ -from datetime import datetime - -import pytest -from six import raise_from - -try: # python 3+ - from typing import Type, Set, Union, Any, Dict -except ImportError: - pass +from typing import Type, Union, Any, Dict from pytest_harvest.common import yield_fixture from pytest_harvest.fixture_cache import saved_fixture @@ -25,19 +17,19 @@ def __setattr__(self, key, value): # try: No exception can happen: key is always a string, and new entries are allowed in a dict self[key] = value # except KeyError as e: - # raise_from(AttributeError(key), e) + # raise AttributeError(key) from e def __getattr__(self, key): try: return self[key] except KeyError as e: - raise_from(AttributeError(key), e) + raise AttributeError(key) from e def __delattr__(self, key): try: del self[key] except KeyError as e: - raise_from(AttributeError(key), e) + raise AttributeError(key) from e # object base def __str__(self): diff --git a/src/pytest_harvest/results_session.py b/src/pytest_harvest/results_session.py index 933ed78..26e1b39 100644 --- a/src/pytest_harvest/results_session.py +++ b/src/pytest_harvest/results_session.py @@ -4,7 +4,6 @@ import sys from collections import OrderedDict, namedtuple from itertools import chain -from six import string_types pytest81 = Version(pytest.__version__) >= Version("8.1.0") @@ -190,7 +189,7 @@ def test_id_format(test_id): if flatten_more is not None: if isinstance(flatten_more, dict): flatten_more_prefixes_dct = flatten_more.items() - elif isinstance(flatten_more, string_types): + elif isinstance(flatten_more, str): # single name ? flatten_more_prefixes_dct = {flatten_more: ''} else: @@ -546,7 +545,7 @@ def _get_filterset(filter): :param filter: :return: """ - if isinstance(filter, string_types): + if isinstance(filter, str): filter = {filter} else: try: diff --git a/tests/test_all_raw_with_meta_check.py b/tests/test_all_raw_with_meta_check.py index 1eb1710..880dc3a 100644 --- a/tests/test_all_raw_with_meta_check.py +++ b/tests/test_all_raw_with_meta_check.py @@ -62,4 +62,4 @@ def test_run_all_tests(test_to_run, testdir): result.assert_outcomes(**asserts_dct) except Exception as e: print("Error while asserting that %s results in %s" % (test_to_run, str(asserts_dct))) - six.raise_from(e, e) + raise e from e From 35c59065fc131ce34392ab43e561440440e49d24 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 13:07:37 +0200 Subject: [PATCH 6/7] Updated changelog --- docs/changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 6555c6e..4bc9680 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,8 +2,8 @@ ### 1.11.0 - dropped support for python < 3.9 and fixed - pytest 8.4.0 (in progress) -- Dropped support for python <3.9 and added a proper github pages workflow (explicit). Fixed - [#79](https://github.com/smarie/python-pytest-harvest/issues/79) +- Dropped support for python <3.9 and added a proper github pages workflow (explicit). Removed `six` from dependencies. + Fixed [#79](https://github.com/smarie/python-pytest-harvest/issues/79) ### 1.10.6 - bugfixes and maintenance chores From 65b09535156055df71c8d788f289e97e8df8a017 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Mon, 9 Jun 2025 14:44:29 +0200 Subject: [PATCH 7/7] Added an upper bound on pytest for the current tests, so that a release can be made --- setup.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6fd7fed..c329944 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,11 +42,9 @@ install_requires = packaging decopatch makefun>=1.5 - # TODO remove and use common_mini_six.py - six tests_require = - pytest + pytest<8.4.0 numpy pandas tabulate