Hi, I just updated pytest from 3.2.1 to 3.8.1 and it breaks some of my tests.
The problem seems to be that the behavior of approx changed. I'm using it with tuples that contain a mix of floats and None values. In 3.2.1, this worked just fine, but in 3.8.1 I get an error. Minimal example:
pytest 3.2.1
C:\Users\felix>python
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 16:13:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pytest import approx
>>> (1, 2, None) == approx((1.000000001, 2, None))
True
pytest 3.8.1
C:\Users\felix>python
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pytest import approx
>>> (1, 2, None) == approx((1.000000001, 2, None))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\felix\AppData\Local\conda\conda\envs\py37\lib\site-packages\_pytest\python_api.py", line 528, in approx
return cls(expected, rel, abs, nan_ok)
File "C:\Users\felix\AppData\Local\conda\conda\envs\py37\lib\site-packages\_pytest\python_api.py", line 64, in __init__
self._check_type()
File "C:\Users\felix\AppData\Local\conda\conda\envs\py37\lib\site-packages\_pytest\python_api.py", line 215, in _check_typ
self.expected, at="index {}".format(index)
TypeError: cannot make approximate comparisons to non-numeric values: (1.000000001, 2, None) at index 2
Is this an intended change? If so, I'd like know if there's a better way to compare tuples like these.
Thanks in advance.
Hi, I just updated pytest from 3.2.1 to 3.8.1 and it breaks some of my tests.
The problem seems to be that the behavior of
approxchanged. I'm using it with tuples that contain a mix of floats and None values. In 3.2.1, this worked just fine, but in 3.8.1 I get an error. Minimal example:pytest 3.2.1
pytest 3.8.1
Is this an intended change? If so, I'd like know if there's a better way to compare tuples like these.
Thanks in advance.