You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When test method argument values (e.g. for parameterized inputs) are arrays, the snapshot lookup fails.
Error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Note: I believe this would also occur with other complex argument types, such as pandas dataframes.
To Reproduce
import pytest
import numpy as np
@pytest.mark.parametrize("my_array", [np.array([-1.0, 0.0, 1.0])])
def test_something(snapshot, my_array):
"""Test with array input argument"""
snapshot.assert_match(5)
This fails on snapshot lookup, so fails on running the test for the 2nd+ time (after snapshot creation).
Error trace:
self = <snappiershot.snapshot.metadata.SnapshotMetadata object at 0x13287b250>
metadata_dict = {'arguments': {'my_array': [-1.0, 0.0, 1.0]}, 'test_runner_provided_name': '', 'update_on_next_run': False, 'user_provided_name': ''}
def matches(self, metadata_dict: Dict) -> bool:
""" Check if the "metadata" section of a snapshot file sufficiently matches
this metadata object.
This matching is used to identify snapshots of tests within a snapshot file.
Args:
metadata_dict: The "metadata" section to compare against this object.
"""
> return self.caller_info.args == metadata_dict["arguments"]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Expected behavior
No failure; correct lookup of associated snapshot
Screenshots
N/A
Versions:
Python version:
Snappiershot version:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
This is an issue with the test function arguments within the metadata needing to be passed through the default_encode_value utility method. This should be relatively straightforward to fix
Describe the bug
When test method argument values (e.g. for parameterized inputs) are arrays, the snapshot lookup fails.
Error:
Note: I believe this would also occur with other complex argument types, such as pandas dataframes.
To Reproduce
This fails on snapshot lookup, so fails on running the test for the 2nd+ time (after snapshot creation).
Error trace:
Expected behavior
No failure; correct lookup of associated snapshot
Screenshots
N/A
Versions:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: