webartifex / lalib

A Python library to study linear algebra
MIT License
1 stars 0 forks source link

pytest does not respect the singleton pattern in Python 3.9 and 3.10 #1

Open webartifex opened 3 weeks ago

webartifex commented 3 weeks ago

one and zero are singletons. Yet, the following does not work with pytest in Python 3.9 and 3.10:

def __eq__(self, other: object) -> bool:
    try:
        other = GF2Element(other)
    except (TypeError, ValueError):
        return False
    else:
        return self is other

return self is other is always False, even if a test case compares, for example, one to one or a one-like other.

For now, use the following fix: return int(self) == int(other)

This issue has no high priority because it only appears in pytest for older Python versions.

webartifex commented 3 weeks ago

Without the temporary fix above, the following GitHub actions don't run successfully: