Skip to content

Commit cd4c1b8

Browse files
authored
Merge branch 'main' into add_pdhdf_file_format
2 parents 91b7403 + c1779e6 commit cd4c1b8

File tree

8 files changed

+111
-62
lines changed

8 files changed

+111
-62
lines changed

.github/workflows/ci_workflows.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
include:
17-
- os: ubuntu-latest
18-
python-version: 3.6
19-
toxenv: py36-test-pytest46
20-
- os: windows-latest
21-
python-version: 3.6
22-
toxenv: py36-test-pytest50
23-
- os: macos-latest
24-
python-version: 3.7
25-
toxenv: py37-test-pytest51
2617
- os: ubuntu-latest
2718
python-version: 3.7
28-
toxenv: py37-test-pytest52
19+
toxenv: py37-test-pytest46
2920
- os: windows-latest
21+
python-version: 3.7
22+
toxenv: py37-test-pytest50
23+
- os: macos-latest
3024
python-version: 3.8
31-
toxenv: py38-test-pytest53
25+
toxenv: py38-test-pytest52
3226
- os: ubuntu-latest
3327
python-version: 3.8
34-
toxenv: py38-test-pytest60
28+
toxenv: py38-test-pytest53
29+
- os: windows-latest
30+
python-version: 3.9
31+
toxenv: py39-test-pytest60
3532
- os: macos-latest
3633
python-version: 3.9
3734
toxenv: py39-test-pytest61
3835
- os: ubuntu-latest
39-
python-version: 3.9
40-
toxenv: py39-test-pytestdev
36+
python-version: '3.10'
37+
toxenv: py310-test-pytest62
38+
- os: ubuntu-latest
39+
python-version: '3.10'
40+
toxenv: py310-test-pytestdev
4141

4242
steps:
4343
- uses: actions/checkout@v2
@@ -47,10 +47,10 @@ jobs:
4747
uses: actions/setup-python@v2
4848
with:
4949
python-version: ${{ matrix.python-version }}
50-
- name: Install Tox
50+
- name: Install tox
5151
run: python -m pip install tox
5252
- name: Install HDF5 (macOS)
5353
run: brew install hdf5 c-blosc
5454
if: matrix.os == 'macos-latest'
55-
- name: Run Tox
55+
- name: Run tox
5656
run: tox -v -e ${{ matrix.toxenv }}

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
build-n-publish:
11+
name: Build and publish Python 🐍 distributions 📦 to PyPI
12+
runs-on: ubuntu-latest
13+
if: ((github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || contains(github.event.pull_request.labels.*.name, 'Build wheels'))
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.8
22+
23+
- name: Install python-build and twine
24+
run: python -m pip install pip build "twine>=3.3" -U
25+
26+
- name: Build package
27+
run: python -m build --sdist --wheel .
28+
29+
- name: List result
30+
run: ls -l dist
31+
32+
- name: Check long_description
33+
run: python -m twine check --strict dist/*
34+
35+
# FIXME: pytest not found
36+
#- name: Test package
37+
# run: |
38+
# cd ..
39+
# python -m venv testenv
40+
# testenv/bin/pip install pytest pytest-arraydiff/dist/*.whl
41+
# testenv/bin/pytest pytest-arraydiff/tests --arraydiff
42+
43+
- name: Publish distribution 📦 to PyPI
44+
if: startsWith(github.ref, 'refs/tags')
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
user: __token__
48+
password: ${{ secrets.pypi_password }}

CHANGES.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
0.4 (unreleased)
1+
0.6 (unreleased)
22
----------------
33

44
- No changes yet.
55
- Add ability to compare to Pandas DataFrames and store them as HDF5 files
66

7+
0.5 (2022-01-12)
8+
----------------
9+
10+
- Removed `astropy` as required dependency. [#31]
11+
12+
- Formally register `array_compare` as marker.
13+
14+
0.4 (2021-12-31)
15+
----------------
16+
17+
- Minimum Python version is now 3.7. [#30]
18+
19+
- Various infrastructure updates.
20+
721
0.3 (2018-12-05)
822
----------------
923

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.5811772.svg
2+
:target: https://doi.org/10.5281/zenodo.5811772
3+
:alt: 10.5281/zenodo.5811772
4+
15
.. image:: https://github.com/astropy/pytest-arraydiff/workflows/CI/badge.svg
26
:target: https://github.com/astropy/pytest-arraydiff/actions
37
:alt: CI Status

pytest_arraydiff/plugin.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,17 @@
3636
import shutil
3737
import tempfile
3838
import warnings
39-
40-
import six
41-
from six.moves.urllib.request import urlopen
39+
from urllib.request import urlopen
4240

4341
import pytest
4442
import numpy as np
4543

4644

47-
if six.PY2:
48-
def abstractstaticmethod(func):
49-
return func
50-
def abstractclassmethod(func):
51-
return func
52-
else:
53-
abstractstaticmethod = abc.abstractstaticmethod
54-
abstractclassmethod = abc.abstractclassmethod
45+
abstractstaticmethod = abc.abstractstaticmethod
46+
abstractclassmethod = abc.abstractclassmethod
5547

5648

57-
@six.add_metaclass(abc.ABCMeta)
58-
class BaseDiff(object):
49+
class BaseDiff(object, metaclass=abc.ABCMeta):
5950

6051
@abstractstaticmethod
6152
def read(filename):
@@ -142,14 +133,7 @@ def read(filename):
142133
@staticmethod
143134
def write(filename, data, **kwargs):
144135
fmt = kwargs.get('fmt', '%g')
145-
# Workaround for a known issue in `numpy.savetxt` for the `fmt` argument:
146-
# https://github.com/numpy/numpy/pull/4053#issuecomment-263808221
147-
# Convert `unicode` to `str` (i.e. bytes) on Python 2
148-
if six.PY2 and isinstance(fmt, six.text_type):
149-
fmt = fmt.encode('ascii')
150-
151136
kwargs['fmt'] = fmt
152-
153137
return np.savetxt(filename, data, **kwargs)
154138

155139

@@ -214,7 +198,9 @@ def pytest_addoption(parser):
214198

215199

216200
def pytest_configure(config):
217-
201+
config.getini('markers').append(
202+
'array_compare: for functions using array comparison')
203+
218204
if config.getoption("--arraydiff") or config.getoption("--arraydiff-generate-path") is not None:
219205

220206
reference_dir = config.getoption("--arraydiff-reference-path")
@@ -325,7 +311,7 @@ def item_function_wrapper(*args, **kwargs):
325311
This is expected for new tests.""".format(
326312
test=test_array))
327313

328-
# distutils may put the baseline arrays in non-accessible places,
314+
# setuptools may put the baseline arrays in non-accessible places,
329315
# copy to our tmpdir to be sure to keep them in case of failure
330316
baseline_file = os.path.abspath(os.path.join(result_dir, 'reference-' + filename))
331317
shutil.copyfile(baseline_file_ref, baseline_file)

setup.cfg

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pytest-arraydiff
3-
url = https://github.com/astrofrog/pytest-arraydiff
3+
url = https://github.com/astropy/pytest-arraydiff
44
author = The Astropy Developers
55
author_email = [email protected]
66
classifiers =
@@ -21,16 +21,20 @@ classifiers =
2121
license = BSD
2222
description = pytest plugin to help with comparing array output from tests
2323
long_description = file: README.rst
24+
long_description_content_type = text/x-rst
2425

2526
[options]
2627
zip_safe = False
2728
packages = find:
28-
python_requires = >=3.6
29+
python_requires = >=3.7
2930
setup_requires =
3031
setuptools_scm
3132
install_requires =
3233
pytest>=4.6
3334
numpy
35+
36+
[options.extras_require]
37+
test =
3438
astropy
3539
pandas
3640
tables
@@ -44,7 +48,7 @@ minversion = 4.6
4448
testpaths = tests
4549
xfail_strict = true
4650
markers =
47-
array_compare : for functions using array comparison
51+
array_compare: for functions using array comparison
4852

4953
[flake8]
50-
max-line-length = 100
54+
max-line-length = 150

tests/test_pytest_arraydiff.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import os
2-
import sys
32
import subprocess
43
import tempfile
54

65
import pytest
76
import numpy as np
87

9-
PY2 = sys.version_info[0] == 2
10-
118
reference_dir = 'baseline'
129

1310

@@ -65,11 +62,11 @@ def test_fails():
6562
f.write(TEST_FAILING)
6663

6764
# If we use --arraydiff, it should detect that the file is missing
68-
code = subprocess.call('py.test --arraydiff {0}'.format(test_file), shell=True)
65+
code = subprocess.call('pytest --arraydiff {0}'.format(test_file), shell=True)
6966
assert code != 0
7067

7168
# If we don't use --arraydiff option, the test should succeed
72-
code = subprocess.call('py.test {0}'.format(test_file), shell=True)
69+
code = subprocess.call('pytest {0}'.format(test_file), shell=True)
7370
assert code == 0
7471

7572

@@ -96,19 +93,13 @@ def test_generate(file_format):
9693

9794
# If we don't generate, the test will fail
9895
try:
99-
if PY2:
100-
subprocess.check_output(['pytest', '--arraydiff', test_file])
101-
else:
102-
subprocess.check_output(['pytest', '--arraydiff', test_file], timeout=10)
96+
subprocess.check_output(['pytest', '--arraydiff', test_file], timeout=10)
10397
except subprocess.CalledProcessError as grepexc:
10498
assert b'File not found for comparison test' in grepexc.output
10599

106100
# If we do generate, the test should succeed and a new file will appear
107-
if PY2:
108-
code = subprocess.call(['pytest', '--arraydiff-generate-path={0}'.format(gen_dir), test_file])
109-
else:
110-
code = subprocess.call(['pytest', '--arraydiff-generate-path={0}'.format(gen_dir), test_file],
111-
timeout=10)
101+
code = subprocess.call(['pytest', '--arraydiff-generate-path={0}'.format(gen_dir), test_file],
102+
timeout=10)
112103
assert code == 0
113104
assert os.path.exists(os.path.join(gen_dir, 'test_gen.' + ('fits' if file_format == 'fits' else 'txt')))
114105

@@ -122,6 +113,7 @@ def test_default():
122113
return np.arange(6 * 5).reshape((6, 5))
123114
"""
124115

116+
125117
@pytest.mark.parametrize('file_format', ('fits', 'text'))
126118
def test_default_format(file_format):
127119

@@ -134,15 +126,15 @@ def test_default_format(file_format):
134126
gen_dir = os.path.join(tmpdir, 'spam', 'egg')
135127

136128
# If we do generate, the test should succeed and a new file will appear
137-
code = subprocess.call('py.test -s --arraydiff-default-format={0}'
129+
code = subprocess.call('pytest -s --arraydiff-default-format={0}'
138130
' --arraydiff-generate-path={1} {2}'.format(file_format, gen_dir, test_file), shell=True)
139131
assert code == 0
140132
assert os.path.exists(os.path.join(gen_dir, 'test_default.' + ('fits' if file_format == 'fits' else 'txt')))
141133

142134

143135
@pytest.mark.array_compare(reference_dir=reference_dir, rtol=0.5, file_format='fits')
144136
def test_tolerance():
145-
return np.ones((3,4)) * 1.6
137+
return np.ones((3, 4)) * 1.6
146138

147139

148140
def test_nofile():

tox.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
envlist =
3-
py{36,37,38,39}-test{,-devdeps}
3+
py{37,38,39,310}-test{,-devdeps}
44
codestyle
55
requires =
66
setuptools >= 30.3.0
@@ -13,13 +13,14 @@ description = run tests
1313
deps =
1414
pytest46: pytest==4.6.*
1515
pytest50: pytest==5.0.*
16-
pytest51: pytest==5.1.*
1716
pytest52: pytest==5.2.*
1817
pytest53: pytest==5.3.*
1918
pytest60: pytest==6.0.*
2019
pytest61: pytest==6.1.*
20+
pytest62: pytest==6.2.*
2121
pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest
22-
22+
extras =
23+
test
2324
commands =
2425
pip freeze
2526
pytest {toxinidir}/tests {posargs}

0 commit comments

Comments
 (0)