diff --git a/pandas/tests/test_expressions.py b/pandas/tests/test_expressions.py index 1974f712b13ee..9808c3d78b436 100644 --- a/pandas/tests/test_expressions.py +++ b/pandas/tests/test_expressions.py @@ -261,9 +261,9 @@ def testit(): def test_bool_ops_raise_on_arithmetic(self, op_str, opname): df = DataFrame({"a": np.random.rand(10) > 0.5, "b": np.random.rand(10) > 0.5}) - msg = "operator %r not implemented for bool dtypes" + msg = f"operator {repr(op_str)} not implemented for bool dtypes" f = getattr(operator, opname) - err_msg = re.escape(msg % op_str) + err_msg = re.escape(msg) with pytest.raises(NotImplementedError, match=err_msg): f(df, df)