I am testing someone elses code with the aim of achieving full coverage, then refactoring while testing. This code has functions which output large arrays with hundreds of elements. The arrays are generated such that I would like to test each value in the array (np.array_equal
). Is there a clean way to do this with pytest
? I am a bit wary of doing something like:
@pytests.mark.unittest
def test_array_function():
expected_result = # explicitly copy and paste a large numpy array with hundreds of elements
result = array_function()
assert np.array_equal(result, expected_result)
EDIT
I have found a similar question here which looks good at first glance. I think this is too complicated for my use case however. I don't understand why the need of creating another temporary directory and moving all expected data files there...