Skip to content

Wrong behavior of test_eq comparing sequences with trailing Nones #519

@civvic

Description

@civvic

Is this intended?:

python -i
Python 3.11.0 | packaged by conda-forge | (main, Jan 15 2023, 05:44:48) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fastcore.test import *
>>> test_eq((13, ), (13, None, ))
>>> test_eq([13, ], [13, None, ])
>>> test_eq([13, 14, ], [13, 14, None, ])
>>> test_eq((13, None, ), (13, ))

Above lines run without problems. My understanding is that any should raise an AssertionError, like, e.g., this below:

>>> test_eq((13, ), (None, 13, ))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/vic/dev/repo/project/sonofcr/proj/socr-server/.micromamba/envs/sonofcr/lib/python3.11/site-packages/fastcore/test.py", line 37, in test_eq
    test(a,b,equals, cname='==')
  File "/Users/vic/dev/repo/project/sonofcr/proj/socr-server/.micromamba/envs/sonofcr/lib/python3.11/site-packages/fastcore/test.py", line 27, in test
    assert cmp(a,b),f"{cname}:\n{a}\n{b}"
AssertionError: ==:
(13,)
(None, 13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions