Repository: pandas-dev/pandas
File: pandas/tests/series/methods/test_compare.py (Python)

Code before:
        {"a": "2015-07-05", "b": "04181 83668"},
    ]
    dtypes = {"a": "datetime64[ns]", "b": "string"}
    df = pd.DataFrame(data=data).astype(dtypes)

    result_eq1 = df["a"].eq(df["b"])
    result_eq2 = df["a"] == df["b"]
    result_neq = df["a"] != df["b"]

    expected_eq = pd.Series([False] * 5)  # For .eq and ==
    expected_neq = pd.Series([True] * 5)  # For !=

    tm.assert_series_equal(result_eq1, expected_eq)
    tm.assert_series_equal(result_eq2, expected_eq)
    tm.assert_series_equal(result_neq, expected_neq)


def test_eq_objects():
    """Test eq with Enum and List elements"""

    class Thing(Enum):
        FIRST = auto()
        SECOND = auto()

    left = pd.Series([Thing.FIRST, Thing.SECOND])
    tm.assert_series_equal(left.eq(Thing.FIRST), left == Thing.FIRST)

    py_l = [Thing.FIRST, Thing.SECOND]
    tm.assert_series_equal(left.eq(py_l), left == py_l)

    np_a = np.asarray(py_l)
    tm.assert_series_equal(left.eq(np_a), left == np_a)

    pd_s = pd.Series(py_l)
    tm.assert_series_equal(left.eq(pd_s), left == pd_s)

    left_non_scalar = pd.Series([[1, 2], [3, 4]])
    with pytest.raises(AssertionError):
        tm.assert_series_equal(left_non_scalar.eq([1, 2]), pd.Series([True, False]))


def test_eq_with_index():
    """Test eq with non-trivial indices"""
    left = pd.Series([1, 2], index=[1, 0])

    py_l = [1, 2]
    tm.assert_series_equal(left.eq(py_l), left == py_l)

    np_a = np.asarray(py_l)
    tm.assert_series_equal(left.eq(np_a), left == np_a)


Review comment (suggestion):
Can you setup the asserts in the following pattern:

```python
expected = ...
result = ...
tm.assert_series_equal(result, expected)
```

Code after:
        {"a": "2015-07-05", "b": "04181 83668"},
    ]
    dtypes = {"a": "datetime64[ns]", "b": "string"}
    df = pd.DataFrame(data=data).astype(dtypes)

    result_eq1 = df["a"].eq(df["b"])
    result_eq2 = df["a"] == df["b"]
    result_neq = df["a"] != df["b"]

    expected_eq = pd.Series([False] * 5)  # For .eq and ==
    expected_neq = pd.Series([True] * 5)  # For !=

    tm.assert_series_equal(result_eq1, expected_eq)
    tm.assert_series_equal(result_eq2, expected_eq)
    tm.assert_series_equal(result_neq, expected_neq)


def test_eq_objects():
    # GH#62191 Test eq with Enum and List elements

    class Thing(Enum):
        FIRST = auto()
        SECOND = auto()

    left = pd.Series([Thing.FIRST, Thing.SECOND])
    py_l = [Thing.FIRST, Thing.SECOND]

    result = left.eq(Thing.FIRST)
    expected = pd.Series([True, False])
    tm.assert_series_equal(result, expected)

    result = left.eq(py_l)
    expected = pd.Series([True, True])
    tm.assert_series_equal(result, expected)

    result = left.eq(np.asarray(py_l))
    expected = pd.Series([True, True])
    tm.assert_series_equal(result, expected)

    result = left.eq(pd.Series(py_l))
    expected = pd.Series([True, True])
    tm.assert_series_equal(result, expected)

    result = pd.Series([[1, 2], [3, 4]]).eq([1, 2])
    expected = pd.Series([True, False])
    with pytest.raises(AssertionError):
        tm.assert_series_equal(result, expected)
    expected = pd.Series([False, False])
    tm.assert_series_equal(result, expected)