Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single_reference=True #43

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
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.function + '.' + extension
astrofrog marked this conversation as resolved.
Show resolved Hide resolved
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
Loading