Open kohr-h opened 6 years ago
Is there some way for us to hook into pytest.approx
and modify it? If we solve
We should be all fine
Looking at the code, I have to revise my opinion. So (1) no, there's no way to hook into it other than forking pytest
and adding more ApproxMyclass
classes, and (2) the array comparison is quite lame, using np.nditer
which is slow, and no optimization for two arrays (in the style of np.allclose
).
I guess I was expecting too much.
The relevant code is here: https://github.com/pytest-dev/pytest/blob/master/_pytest/python_api.py
The
pytest.approx
function can be used for scalar comparison, but also for sequences, dicts, and since version 3.2.0 also for Numpy arrays. What it doesn't handle is nested sequences, so we can't replace everything by it.But maybe we can reduce our own logic significantly and delegate more to
pytest.approx
?