Skip to content

Commit

Permalink
Merge pull request #43 from pllim/fix-single-ref
Browse files Browse the repository at this point in the history
Fix single_reference=True
  • Loading branch information
astrofrog authored Nov 27, 2023
2 parents ebafbeb + 86e919e commit f392f6f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
0.7 (unreleased)
----------------

- Fix broken ``single_reference=True`` usage. [#43]

0.6 (2023-11-15)
----------------

Expand Down
6 changes: 4 additions & 2 deletions pytest_arraydiff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Binary file added tests/baseline/test_single_reference.fits
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/test_pytest_arraydiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f392f6f

Please sign in to comment.