AnswerDotAI / AnswerDotAI/fastcore

Wrong behavior of test_eq comparing sequences with trailing Nones

Open
#519 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.1k
Forks
295
Avg merge
1d 6h
Merged PRs (30d)
7

Description

Is this intended?:
```python
❯ 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:
```python
>>> test_eq((13, ), (None, 13, ))
Traceback (most recent call last):
File "", line 1, in
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)
```

Contributor guide

Open the contributing guide

Research direction

Start in fastcore/test.py at test_eq and reproduce the four trailing-None examples from the issue. Review existing tests for sequence comparison to determine whether trailing None values are intended to be ignored; done means the expected behavior is established and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.