Repository: pandas-dev/pandas
File: pandas/tests/extension/test_integer.py (Python)

Code before:
                # see https://github.com/pandas-dev/pandas/issues/22024
                expected = expected.astype(s.dtype)
                result = result.astype(s.dtype)
            else:
                # combine method result in 'biggest' (int64) dtype
                expected = expected.astype(s.dtype)
                pass
            if (op_name == '__rpow__') and isinstance(other, pd.Series):
                # TODO pow on Int arrays gives different result with NA
                # see https://github.com/pandas-dev/pandas/issues/22022
                result = result.fillna(1)

            self.assert_series_equal(result, expected)
        else:
            with pytest.raises(exc):
                op(s, other)

    def _check_divmod_op(self, s, op, other, exc=None):
        super(TestArithmeticOps, self)._check_divmod_op(s, op, other, None)

    @pytest.mark.skip(reason="intNA does not error on ops")
    def test_error(self, data, all_arithmetic_operators):
        # other specific errors tested in the integer array specific tests
        pass


class TestComparisonOps(base.BaseComparisonOpsTests):

    def check_opname(self, s, op_name, other, exc=None):
        super(TestComparisonOps, self).check_opname(s, op_name,
                                                    other, exc=None)

    def _compare_other(self, s, data, op_name, other):
        self.check_opname(s, op_name, other)


class TestInterface(base.BaseInterfaceTests):
    pass


class TestConstructors(base.BaseConstructorsTests):
    pass


class TestReshaping(base.BaseReshapingTests):
    pass

    # for test_concat_mixed_dtypes test
    # concat of an Integer and Int coerces to object dtype
    # TODO(jreback) once integrated this would


Review comment (bug):
So, here's what's happening for IntegerArray with missing values,

Because of #22922, the ExtensionArray is listified, so we do `IntegerArray + List`. Then, in `IntegerArray.__add__` we do `np.asarray(other)`. Since we have missing values, we naturally end up with a float ndarray.

Fixing #22922 will fix this specific issue, but doesn't handle the general problem of `IntegerArray + List`. i.e. is this a bug?

```python
In [3]: arr = pd.Series([1, None, 3], dtype='Int8').values

In [4]: arr
Out[4]: IntegerArray([1, nan, 3], dtype='Int8')

In [5]: arr + list(arr)
Out[5]: array([ 2., nan,  6.])
```

Should `Out[5]` be an `IntegerArray([2, nan, 6], dtype='Int8')`? If so, I'll open a new issue.

Code after:
                # see https://github.com/pandas-dev/pandas/issues/22024
                expected = expected.astype(s.dtype)
                result = result.astype(s.dtype)
            else:
                # combine method result in 'biggest' (int64) dtype
                expected = expected.astype(s.dtype)
                pass
            if (op_name == '__rpow__') and isinstance(other, pd.Series):
                # TODO pow on Int arrays gives different result with NA
                # see https://github.com/pandas-dev/pandas/issues/22022
                result = result.fillna(1)

            self.assert_series_equal(result, expected)
        else:
            with pytest.raises(exc):
                op(s, other)

    def _check_divmod_op(self, s, op, other, exc=None):
        super(TestArithmeticOps, self)._check_divmod_op(s, op, other, None)

    @pytest.mark.skip(reason="intNA does not error on ops")
    def test_error(self, data, all_arithmetic_operators):
        # other specific errors tested in the integer array specific tests
        pass

    @pytest.mark.xfail(reason="EA is listified. GH-22922", strict=True)
    def test_add_series_with_extension_array(self, data):
        super(TestArithmeticOps, self).test_add_series_with_extension_array(
            data
        )


class TestComparisonOps(base.BaseComparisonOpsTests):

    def check_opname(self, s, op_name, other, exc=None):
        super(TestComparisonOps, self).check_opname(s, op_name,
                                                    other, exc=None)

    def _compare_other(self, s, data, op_name, other):
        self.check_opname(s, op_name, other)


class TestInterface(base.BaseInterfaceTests):
    pass


class TestConstructors(base.BaseConstructorsTests):
    pass


class TestReshaping(base.BaseReshapingTests):