Skip to content

Commit bdd95ab

Browse files
committed
fix: update error messages in tests to use EXPR_TYPE_ERROR for consistency
1 parent 1bbb6ad commit bdd95ab

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

python/tests/test_dataframe.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
get_formatter,
4747
reset_formatter,
4848
)
49-
from datafusion.expr import Window
49+
from datafusion.expr import EXPR_TYPE_ERROR, Window
5050
from pyarrow.csv import write_csv
5151

5252
MB = 1024 * 1024
@@ -232,7 +232,8 @@ def test_select_mixed_expr_string(df):
232232

233233
def test_select_unsupported(df):
234234
with pytest.raises(
235-
TypeError, match=r"Expected Expr or column name.*col\(\) or lit\(\)"
235+
TypeError,
236+
match=f"Expected Expr or column name.*{re.escape(EXPR_TYPE_ERROR)}",
236237
):
237238
df.select(1)
238239

@@ -288,7 +289,8 @@ def test_sort_string_and_expression_equivalent(df):
288289

289290
def test_sort_unsupported(df):
290291
with pytest.raises(
291-
TypeError, match=r"Expected Expr or column name.*col\(\) or lit\(\)"
292+
TypeError,
293+
match=f"Expected Expr or column name.*{re.escape(EXPR_TYPE_ERROR)}",
292294
):
293295
df.sort(1)
294296

@@ -302,7 +304,7 @@ def test_aggregate_string_and_expression_equivalent(df):
302304

303305

304306
def test_filter_string_unsupported(df):
305-
with pytest.raises(TypeError, match=r"col\(\) or lit\(\)"):
307+
with pytest.raises(TypeError, match=re.escape(EXPR_TYPE_ERROR)):
306308
df.filter("a > 1")
307309

308310

python/tests/test_expr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
import re
1819
from datetime import datetime, timezone
1920

2021
import pyarrow as pa
@@ -28,6 +29,7 @@
2829
literal_with_metadata,
2930
)
3031
from datafusion.expr import (
32+
EXPR_TYPE_ERROR,
3133
Aggregate,
3234
AggregateFunction,
3335
BinaryExpr,
@@ -886,5 +888,5 @@ def test_literal_metadata(ctx):
886888
def test_ensure_expr():
887889
e = col("a")
888890
assert ensure_expr(e) is e.expr
889-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
891+
with pytest.raises(TypeError, match=re.escape(EXPR_TYPE_ERROR)):
890892
ensure_expr("a")

0 commit comments

Comments
 (0)