1
1
import operator
2
+ from tokenize import TokenError
2
3
3
4
import numpy as np
4
5
import pytest
@@ -1446,7 +1447,7 @@ def test_expr_with_no_backticks(self):
1446
1447
def test_expr_with_no_quotes_and_backtick_is_unmatched (self ):
1447
1448
# GH 59285
1448
1449
df = DataFrame ((1 , 5 , 10 ), columns = ["column-name" ])
1449
- with pytest .raises (SyntaxError , match = "invalid syntax" ):
1450
+ with pytest .raises (( SyntaxError , TokenError ) , match = "invalid syntax" ):
1450
1451
df .query ("5 < `column-name" )
1451
1452
1452
1453
def test_expr_with_no_quotes_and_backtick_is_matched (self ):
@@ -1459,7 +1460,9 @@ def test_expr_with_no_quotes_and_backtick_is_matched(self):
1459
1460
def test_expr_with_backtick_opened_before_quote_and_backtick_is_unmatched (self ):
1460
1461
# GH 59285
1461
1462
df = DataFrame ((1 , 5 , 10 ), columns = ["It's" ])
1462
- with pytest .raises (SyntaxError , match = "unterminated string literal" ):
1463
+ with pytest .raises (
1464
+ (SyntaxError , TokenError ), match = "unterminated string literal"
1465
+ ):
1463
1466
df .query ("5 < `It's" )
1464
1467
1465
1468
def test_expr_with_backtick_opened_before_quote_and_backtick_is_matched (self ):
@@ -1472,7 +1475,9 @@ def test_expr_with_backtick_opened_before_quote_and_backtick_is_matched(self):
1472
1475
def test_expr_with_quote_opened_before_backtick_and_quote_is_unmatched (self ):
1473
1476
# GH 59285
1474
1477
df = DataFrame (("aaa" , "vvv" , "zzz" ), columns = ["column-name" ])
1475
- with pytest .raises (SyntaxError , match = "unterminated string literal" ):
1478
+ with pytest .raises (
1479
+ (SyntaxError , TokenError ), match = "unterminated string literal"
1480
+ ):
1476
1481
df .query ("`column-name` < 'It`s that\\ 's \" quote\" #hash" )
1477
1482
1478
1483
def test_expr_with_quote_opened_before_backtick_and_quote_is_matched_at_end (self ):
0 commit comments