diff --git a/CHANGES.md b/CHANGES.md index f78d710..e9643bc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +0.6.1 (2023-11-27) +------------------ + +- Fix broken ``single_reference=True`` usage. [#43] + 0.6 (2023-11-15) ---------------- diff --git a/README.rst b/README.rst index 48136ea..a4e33ad 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,10 @@ :target: https://github.com/astropy/pytest-arraydiff/actions :alt: CI Status +.. image:: https://img.shields.io/pypi/v/pytest-arraydiff.svg + :target: https://pypi.org/project/pytest-arraydiff + :alt: PyPI Status + About ----- diff --git a/pytest_arraydiff/plugin.py b/pytest_arraydiff/plugin.py index f476e68..825c9b6 100755 --- a/pytest_arraydiff/plugin.py +++ b/pytest_arraydiff/plugin.py @@ -310,8 +310,10 @@ def pytest_runtest_call(self, item): # Find test name to use as plot name filename = compare.kwargs.get('filename', None) if filename is None: - filename = item.name + '.' + extension - if not single_reference: + if single_reference: + filename = item.originalname + '.' + extension + else: + filename = item.name + '.' + extension filename = filename.replace('[', '_').replace(']', '_') filename = filename.replace('_.' + extension, '.' + extension) diff --git a/tests/baseline/test_single_reference.fits b/tests/baseline/test_single_reference.fits new file mode 100644 index 0000000..9fab1ae Binary files /dev/null and b/tests/baseline/test_single_reference.fits differ diff --git a/tests/test_pytest_arraydiff.py b/tests/test_pytest_arraydiff.py index 5ad20dc..da603fa 100644 --- a/tests/test_pytest_arraydiff.py +++ b/tests/test_pytest_arraydiff.py @@ -152,5 +152,27 @@ def test_absolute_tolerance(): return np.ones((3, 4)) * 1.6 + 1.4 +@pytest.mark.array_compare( + reference_dir=reference_dir, + atol=1.5, + file_format='fits', + single_reference=True) +@pytest.mark.parametrize('spam', ('egg', 'bacon')) +def test_single_reference(spam): + return np.ones((3, 4)) * 1.6 + 1.4 + + +class TestSingleReferenceClass: + + @pytest.mark.array_compare( + reference_dir=reference_dir, + atol=1.5, + file_format='fits', + single_reference=True) + @pytest.mark.parametrize('spam', ('egg', 'bacon')) + def test_single_reference(self, spam): + return np.ones((3, 4)) * 1.6 + 1.4 + + def test_nofile(): pass diff --git a/tox.ini b/tox.ini index bde33c9..7fda9f0 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ isolated_build = true [testenv] changedir = .tmp/{envname} setenv = - devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/liberfa/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple description = run tests deps = pytestoldest: pytest==4.6.0 @@ -28,6 +28,7 @@ deps = devdeps: git+https://github.com/pytest-dev/pytest#egg=pytest devdeps: numpy>=0.0.dev0 devdeps: pandas>=0.0.dev0 + devdeps: pyerfa>=0.0.dev0 devdeps: astropy>=0.0.dev0 extras = test