Skip to content

Commit a5f8c9a

Browse files
authored
TST: Catch warnings due to division by 0 (#42836)
1 parent c79e7ee commit a5f8c9a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/tests/test_expressions.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import operator
22
import re
3+
import warnings
34

45
import numpy as np
56
import pytest
@@ -167,8 +168,12 @@ def testit():
167168

168169
op = getattr(operator, opname)
169170

170-
result = expr.evaluate(op, left, left, use_numexpr=True)
171-
expected = expr.evaluate(op, left, left, use_numexpr=False)
171+
with warnings.catch_warnings():
172+
# array has 0s
173+
msg = "invalid value encountered in true_divide"
174+
warnings.filterwarnings("ignore", msg, RuntimeWarning)
175+
result = expr.evaluate(op, left, left, use_numexpr=True)
176+
expected = expr.evaluate(op, left, left, use_numexpr=False)
172177
tm.assert_numpy_array_equal(result, expected)
173178

174179
result = expr._can_use_numexpr(op, op_str, right, right, "evaluate")

0 commit comments

Comments
 (0)