From f8c4d5af6c36a15d12ff00dc258be6936dc0e50c Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Wed, 18 Jun 2025 16:40:52 +0200 Subject: [PATCH 1/6] Update to setup.cfg --- setup.cfg | 27 +++++++++++++++++++++++++++ setup.py | 33 +-------------------------------- 2 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..d2f03df --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[metadata] +name = pytest-persistence +version = 0.1.11 +description = Pytest plugin for persistent objects +author = Jakub Urban +author_email = kubo.urban@gmail.com +maintainer = Matej Dujava +maintainer_email = mdujava@redhat.com +url = https://github.com/3scale-qe/pytest-persistence +long_description = file: README.md +classifiers = + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 + Framework :: Pytest + Operating System :: OS Independent + License :: OSI Approved :: MIT License + +[options] +packages = pytest_persistence + +[options.entry_points] +pytest11 = + persistence = pytest_persistence.plugin diff --git a/setup.py b/setup.py index 109732c..8bf1ba9 100644 --- a/setup.py +++ b/setup.py @@ -1,33 +1,2 @@ -"""This module makes the pytest_persistence plugin pip installable.""" from setuptools import setup - -from pytest_persistence import __version__ - -with open("README.md", "r") as fh: - long_description = fh.read() - -extra_requirements = { - 'dev': [ - 'pytest' - ] -} - -setup(name="pytest-persistence", - version=__version__, - description="Pytest tool for persistent objects", - author="Jakub Urban", - author_email="kubo.urban@gmail.com", - maintainer="Jakub Urban", - url="https://github.com/JaurbanRH/pytest-persistence", - packages=["pytest_persistence"], - long_description=long_description, - entry_points={ - "pytest11": ["persistence = pytest_persistence.plugin"] - }, - classifiers=[ - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Operating System :: OS Independent", - "License :: OSI Approved :: MIT License", - ], - ) +setup() From a37c05e2a88931d2ee34a84eb49d204432a99293 Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Fri, 20 Jun 2025 17:37:11 +0200 Subject: [PATCH 2/6] Update setup.py and tox --- setup.cfg | 24 ++++++++++++++++-------- tox.ini | 3 ++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/setup.cfg b/setup.cfg index d2f03df..a17f563 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,20 +8,28 @@ maintainer = Matej Dujava maintainer_email = mdujava@redhat.com url = https://github.com/3scale-qe/pytest-persistence long_description = file: README.md +license = Apache-2.0 +license_files = LICENSE classifiers = - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 - Framework :: Pytest Operating System :: OS Independent - License :: OSI Approved :: MIT License + Intended Audience :: Developers + Framework :: Pytest + Programming Language :: Python :: 3 [options] packages = pytest_persistence +install_requires = + pytest [options.entry_points] pytest11 = persistence = pytest_persistence.plugin + +[flake8] +max-line-length = 120 +ignore = E203,W503 + +[mypy] +ignore_missing_imports = True +check_untyped_defs = true +local_partial_types = true diff --git a/tox.ini b/tox.ini index 7097cd5..dcfb885 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,11 @@ [tox] -envlist = py-pytest{744,800,-latest} +envlist = py-pytest{744,800,840,-latest} [testenv] deps = pytest744: pytest==7.4.4 pytest800: pytest==8.0.0 + pytest840: pytest==8.4.0 pytest-latest: pytest pytest-xdist commands = From 48972ce4e36d369173204d11fd60211b9cf9fa30 Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Fri, 20 Jun 2025 18:51:05 +0200 Subject: [PATCH 3/6] Run tox on PR --- .github/workflows/tox.yml | 63 +++++++++++++++++++++++++++++++++++++++ tox.ini | 8 ++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tox.yml diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 0000000..bba7792 --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,63 @@ +name: check +on: + workflow_dispatch: + push: + branches: ["main"] + tags-ignore: ["**"] + pull_request: + +concurrency: + group: check-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: test with ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - "3.13" + - "3.12" + - "3.11" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' # caching pip dependencies + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Test with tox + run: tox + flake8: + name: flake8 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + cache: 'pip' # caching pip dependencies + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 black mypy + - name: Run flake8 + run: | + flake8 pytest_persistence/ + - name: Run black + run: | + black --check pytest_persistence/ + - name: Run mypy + run: | + mypy pytest_persistence/ diff --git a/tox.ini b/tox.ini index dcfb885..a414836 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,11 @@ [tox] -envlist = py-pytest{744,800,840,-latest} +envlist = py{311,312,313}-pytest{744,800,840,-latest} + +[gh-actions] +python = + 3.13: py313 + 3.12: py312 + 3.11: py311 [testenv] deps = From cc963988144b700c4411c0ac1ffa38ade74a6df7 Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Fri, 20 Jun 2025 19:13:45 +0200 Subject: [PATCH 4/6] Run black formater --- pytest_persistence/XDistScheduling.py | 2 +- pytest_persistence/__init__.py | 1 - pytest_persistence/plugin.py | 23 +++++++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pytest_persistence/XDistScheduling.py b/pytest_persistence/XDistScheduling.py index c8023b1..57c68ae 100644 --- a/pytest_persistence/XDistScheduling.py +++ b/pytest_persistence/XDistScheduling.py @@ -30,7 +30,7 @@ def schedule(self): if self.maxschedchunk is None: self.maxschedchunk = len(self.collection) - for (test, gw) in self.test_order.items(): + for test, gw in self.test_order.items(): node = [x for x in self.nodes if x.gateway.id == gw][0] test_id = self.collection.index(test) self.node2pending[node].append(test_id) diff --git a/pytest_persistence/__init__.py b/pytest_persistence/__init__.py index 13b7089..e69de29 100644 --- a/pytest_persistence/__init__.py +++ b/pytest_persistence/__init__.py @@ -1 +0,0 @@ -__version__ = '0.1.11' diff --git a/pytest_persistence/plugin.py b/pytest_persistence/plugin.py index e4a0628..843cae0 100644 --- a/pytest_persistence/plugin.py +++ b/pytest_persistence/plugin.py @@ -12,17 +12,24 @@ def pytest_addoption(parser): """ Add option to store/load fixture results into file """ - parser.addoption( - "--store", action="store", default=False, help="Store config") - parser.addoption( - "--load", action="store", default=False, help="Load config") + parser.addoption("--store", action="store", default=False, help="Store config") + parser.addoption("--load", action="store", default=False, help="Load config") class Plugin: """ Pytest persistence plugin """ - output = {"session": {}, "package": {}, "module": {}, "class": {}, "function": {}, "workers": {}, "tests": {}} + + output = { + "session": {}, + "package": {}, + "module": {}, + "class": {}, + "function": {}, + "workers": {}, + "tests": {}, + } input = {} unable_to_pickle = set() pickled_fixtures = set() @@ -37,7 +44,7 @@ def pytest_sessionstart(self, session): if os.path.isfile(file): raise FileExistsError("This file already exists") if file := session.config.getoption("--load"): - with open(file, 'rb') as f: + with open(file, "rb") as f: self.input = pickle.load(f) def check_output(self): @@ -67,7 +74,7 @@ def check_fixtures(fixtures): def output_to_file(self, filename): """Serialize output dict into file""" - with open(filename, 'wb') as outfile: + with open(filename, "wb") as outfile: self.check_output() pickle.dump(self.output, outfile) @@ -90,7 +97,7 @@ def pytest_sessionfinish(self, session): workers = None if workers: for i in range(workers): - with open(f"{file}_gw{i}", 'rb') as f: + with open(f"{file}_gw{i}", "rb") as f: self.merge_dicts(pickle.load(f)) os.remove(f"{file}_gw{i}") self.output_to_file(file) From e51065e9aef282dc05939be12f8bf662881439a0 Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Mon, 23 Jun 2025 14:48:14 +0200 Subject: [PATCH 5/6] publish as Trusted Publisher --- .github/workflows/release.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..32a49c8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: release +on: + push: + tags: + - v* +jobs: + release: + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pytest-persistence + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: setup + run: pip install wheel + - name: build + run: python setup.py sdist bdist_wheel + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From 9a0c4039af08032cec249cfeb399ee73f460f586 Mon Sep 17 00:00:00 2001 From: Matej Dujava Date: Mon, 23 Jun 2025 14:48:50 +0200 Subject: [PATCH 6/6] bump for 0.1.12 release --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a17f563..c0ff00f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pytest-persistence -version = 0.1.11 +version = 0.1.12 description = Pytest plugin for persistent objects author = Jakub Urban author_email = kubo.urban@gmail.com