smarie / python-pytest-harvest

Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
https://smarie.github.io/python-pytest-harvest/
BSD 3-Clause "New" or "Revised" License
61 stars 8 forks source link

test_results_bag_basic fails on i386 #26

Closed keszybz closed 4 years ago

keszybz commented 4 years ago
>       assert hash(r) == id(r)
E       assert 1826907305 == 3974390952
E         -1826907305
E         +3974390952

This is easily reproducible:

>>> b = pytest_harvest.ResultsBag()
>>> id(b)
4138743048
>>> hash(b)
1991259401
>>> b.__hash__()
4138743048
>>> hex(hash(b))
'0x76b03509'
>>> hex(b.__hash__())
'0xf6b03508'
>>> bin(hash(b))
'0b1110110101100000011010100001001'
>>> bin(b.__hash__())
'0b11110110101100000011010100001000'
>>> len('1110110101100000011010100001001')
31
>>> len('11110110101100000011010100001000')
32
>>> import sys; print(sys.hash_info.width)
32
>>> sys.version
'3.8.0rc1 (default, Oct  1 2019, 00:00:00) \n[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]'

I'm not sure if python version is relevant...

keszybz commented 4 years ago

See https://docs.python.org/3.8/reference/datamodel.html#object.__hash__. The width is 32, so there shouldn't be truncation, but maybe it's an issue of signed vs. unsigned.