Skip to content

Commit 2ca1891

Browse files
authored
Chore: Switch to Hatch (#66)
1 parent 4194258 commit 2ca1891

File tree

10 files changed

+128
-697
lines changed

10 files changed

+128
-697
lines changed

.github/workflows/nightly.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,58 @@
1-
name: test
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- master
7-
tags-ignore:
8-
- v*
7+
8+
schedule:
9+
- cron: '0 16 * * *' # Run daily at 14:00 UTC
10+
911
pull_request:
10-
workflow_call:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ ! contains(github.ref, github.event.repository.default_branch) }}
1116

1217
jobs:
1318
test:
14-
runs-on: ${{ matrix.os }}
19+
name: ${{ matrix.python-version }}
20+
runs-on: ubuntu-latest
1521
strategy:
1622
fail-fast: false
1723
matrix:
18-
python: ["3.7", "3.8", "3.9", "3.10", "~3.11.0-0", "pypy-3.8"]
19-
os: [ubuntu-latest, windows-latest]
24+
python-version: ["3.7", "3.8", "3.9", "3.10"]
2025
include:
21-
- python: "3.7"
22-
tox_env: "py37"
23-
- python: "3.8"
24-
tox_env: "py38"
25-
- python: "3.9"
26-
tox_env: "py39"
27-
- python: "3.10"
28-
tox_env: "py310"
29-
- python: "~3.11.0-0" # see https://github.com/actions/setup-python/issues/213#issuecomment-1146676713
30-
tox_env: "py311"
31-
- python: "pypy-3.8"
32-
tox_env: "pypy3"
26+
- python-version: pypy3.9
27+
tox-env: py3.9
28+
- python-version: 3.11-dev
29+
tox-env: devel
30+
3331
steps:
3432
- uses: actions/checkout@v3
35-
- name: Set up Python
33+
34+
- name: Set up python
3635
uses: actions/setup-python@v4
3736
with:
38-
python-version: ${{ matrix.python }}
37+
python-version: ${{ matrix.python-version }}
38+
3939
- name: Install tox
4040
run: |
4141
python -m pip install --upgrade pip
4242
pip install tox
43+
4344
- name: Cache tox environments
4445
uses: actions/cache@v3
4546
with:
4647
path: .tox
47-
# increment if issues with cache
48-
key: tox-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}-01
49-
- name: Test
50-
run: tox -e ${{ matrix.tox_env }}
48+
key: tox-ubuntu-latest-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
49+
restore-keys: |
50+
tox-ubuntu-latest-${{ matrix.python-version }}-
51+
52+
- name: Run tests
53+
if: ${{ ! matrix.tox-env }}
54+
run: tox -e py${{ matrix.python-version }}
55+
56+
- name: Run tests
57+
if: ${{ matrix.tox-env }}
58+
run: tox -e ${{ matrix.tox-env }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__
2+
__version.py
23
*.egg-info/
34
*.pyc
45
.cache
@@ -7,5 +8,3 @@ __pycache__
78

89
build
910
dist
10-
11-
pytest_metadata/__version.py

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Release Notes
44
3.0.0 (unreleased)
55
------------------
66

7+
* Switch to Hatch
8+
79
* Use `pytest.stash` internally instead of `_metadata`
810

911
* Simplify code

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ To add/modify/delete metadata at the end of metadata collection, you can use the
151151
.. code-block:: python
152152
153153
import pytest
154-
@pytest.mark.optionalhook
154+
@pytest.hookimpl(optionalhook=True)
155155
def pytest_metadata(metadata):
156156
metadata.pop("password", None)
157157
@@ -163,14 +163,14 @@ fixture:
163163
def test_metadata(metadata):
164164
assert 'metadata' in metadata['Plugins']
165165
166-
To access the metadata from a plugin, you can use the ``_metadata`` attribute of
166+
To access the metadata from a plugin, you can use the ``stash`` attribute of
167167
the ``config`` object. This can be used to read/add/modify the metadata:
168168

169169
.. code-block:: python
170170
171171
def pytest_configure(config):
172-
if hasattr(config, '_metadata'):
173-
config._metadata['foo'] = 'bar'
172+
from pytest_metadata.plugin import metadata_key
173+
config.stash[metadata_key]['foo'] = 'bar'
174174
175175
Plugin integrations
176176
-------------------

0 commit comments

Comments
 (0)