Skip to content

Commit acd2f5f

Browse files
authored
CI: Test pandas warnings as error on some builds (pandas-dev#50386)
1 parent 502919e commit acd2f5f

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

.github/workflows/macos-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
PANDAS_CI: 1
1717
PYTEST_TARGET: pandas
1818
PATTERN: "not slow and not db and not network and not single_cpu"
19-
TEST_ARGS: "-W error:::pandas"
19+
ERROR_ON_WARNINGS: "1"
2020

2121

2222
permissions:

.github/workflows/ubuntu.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: "Minimum Versions"
3939
env_file: actions-38-minimum_versions.yaml
4040
pattern: "not slow and not network and not single_cpu"
41-
test_args: ""
41+
error_on_warnings: "0"
4242
- name: "Locale: it_IT"
4343
env_file: actions-38.yaml
4444
pattern: "not slow and not network and not single_cpu"
@@ -63,20 +63,22 @@ jobs:
6363
env_file: actions-310.yaml
6464
pattern: "not slow and not network and not single_cpu"
6565
pandas_copy_on_write: "1"
66-
test_args: ""
66+
error_on_warnings: "0"
6767
- name: "Data Manager"
6868
env_file: actions-38.yaml
6969
pattern: "not slow and not network and not single_cpu"
7070
pandas_data_manager: "array"
71-
test_args: ""
71+
error_on_warnings: "0"
7272
- name: "Pypy"
7373
env_file: actions-pypy-38.yaml
7474
pattern: "not slow and not network and not single_cpu"
7575
test_args: "--max-worker-restart 0"
76+
error_on_warnings: "0"
7677
- name: "Numpy Dev"
7778
env_file: actions-310-numpydev.yaml
7879
pattern: "not slow and not network and not single_cpu"
7980
test_args: "-W error::DeprecationWarning:numpy -W error::FutureWarning:numpy"
81+
error_on_warnings: "0"
8082
exclude:
8183
- env_file: actions-38.yaml
8284
pyarrow_version: "7"
@@ -96,11 +98,12 @@ jobs:
9698
ENV_FILE: ci/deps/${{ matrix.env_file }}
9799
PATTERN: ${{ matrix.pattern }}
98100
EXTRA_APT: ${{ matrix.extra_apt || '' }}
101+
ERROR_ON_WARNINGS: ${{ matrix.error_on_warnings || '1' }}
99102
LANG: ${{ matrix.lang || '' }}
100103
LC_ALL: ${{ matrix.lc_all || '' }}
101104
PANDAS_DATA_MANAGER: ${{ matrix.pandas_data_manager || 'block' }}
102105
PANDAS_COPY_ON_WRITE: ${{ matrix.pandas_copy_on_write || '0' }}
103-
TEST_ARGS: ${{ matrix.test_args || '-W error:::pandas' }}
106+
TEST_ARGS: ${{ matrix.test_args || '' }}
104107
PYTEST_WORKERS: ${{ contains(matrix.pattern, 'not single_cpu') && 'auto' || '1' }}
105108
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}
106109
IS_PYPY: ${{ contains(matrix.env_file, 'pypy') }}

ci/run_tests.sh

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ if [[ "$PATTERN" ]]; then
3030
PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\""
3131
fi
3232

33+
if [[ "$ERROR_ON_WARNINGS" == "1" ]]; then
34+
for pth in $(find pandas -name '*.py' -not -path "pandas/tests/*" | sed -e 's/\.py//g' -e 's/\/__init__//g' -e 's/\//./g');
35+
do
36+
PYTEST_CMD="$PYTEST_CMD -W error:::$pth"
37+
done
38+
fi
39+
3340
echo $PYTEST_CMD
3441
sh -c "$PYTEST_CMD"
3542

pandas/tests/arithmetic/test_timedelta64.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,18 @@ def test_td64arr_floordiv_td64arr_with_nat(
17561756
# columns without missing values
17571757
expected[[0, 1]] = expected[[0, 1]].astype("int64")
17581758

1759-
result = left // right
1759+
with tm.maybe_produces_warning(
1760+
RuntimeWarning, box is pd.array, check_stacklevel=False
1761+
):
1762+
result = left // right
17601763

17611764
tm.assert_equal(result, expected)
17621765

17631766
# case that goes through __rfloordiv__ with arraylike
1764-
result = np.asarray(left) // right
1767+
with tm.maybe_produces_warning(
1768+
RuntimeWarning, box is pd.array, check_stacklevel=False
1769+
):
1770+
result = np.asarray(left) // right
17651771
tm.assert_equal(result, expected)
17661772

17671773
@pytest.mark.filterwarnings("ignore:invalid value encountered:RuntimeWarning")

0 commit comments

Comments
 (0)