Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion pytest_persistence/XDistScheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pytest_persistence/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = '0.1.11'
23 changes: 15 additions & 8 deletions pytest_persistence/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
35 changes: 35 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[metadata]
name = pytest-persistence
version = 0.1.12
description = Pytest plugin for persistent objects
author = Jakub Urban
author_email = [email protected]
maintainer = Matej Dujava
maintainer_email = [email protected]
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
33 changes: 1 addition & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down