Prefer using `assert_<object>_equal` over `assert_eq` in Python tests
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
Our Python tests make heavy use of `assert_eq` for assertions, and while sufficient, IMO it would be preferable to use the more specific class asserters e.g. `assert_index_equal`, `assert_series_equal` when possible. Some benefits would include:
1. **More self documenting:**: It may not be obvious what type `result` and `expected` should be if they are both generated after multiple API calls.
2. **Avoid `result` and `expected` changing type together**: In a rare instance if both arguments changed together to a different type, `assert_eq` might still allow the assertion to pass instead of fail if it was an unintentional change.
3. **Stricter type checks**: `assert_eq` compares a cudf object as a pandas object and a cupy object as a numpy object. If we're not asserting that a cudf result is comparable to it's CPU counterpart, it would be better to strictly assert we're returning a cudf/cupy object in a test.
A note on 3. It may be beneficial to have a `def assert_eq_to_pandas(cudf_object, pandas_object):` method to more explicitly signal that a cudf object should be compared to similar pandas object
Contributor guide
Assessment
This issue has not been assessed yet.