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 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/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) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c0ff00f --- /dev/null +++ b/setup.cfg @@ -0,0 +1,35 @@ +[metadata] +name = pytest-persistence +version = 0.1.12 +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 +license = Apache-2.0 +license_files = LICENSE +classifiers = + Operating System :: OS Independent + 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/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() diff --git a/tox.ini b/tox.ini index 7097cd5..a414836 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,17 @@ [tox] -envlist = py-pytest{744,800,-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 = pytest744: pytest==7.4.4 pytest800: pytest==8.0.0 + pytest840: pytest==8.4.0 pytest-latest: pytest pytest-xdist commands =