diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test_jsonpath.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_jsonpath.py b/tests/test_jsonpath.py index 4daf3c1..c939c52 100644 --- a/tests/test_jsonpath.py +++ b/tests/test_jsonpath.py @@ -2,8 +2,9 @@ import json import os import unittest -from sqlglot import exp, jsonpath +from sqlglot import exp from sqlglot.errors import ParseError, TokenError +from sqlglot.jsonpath import parse from tests.helpers import FIXTURES_DIR @@ -25,7 +26,7 @@ class TestJsonpath(unittest.TestCase): exp.JSONPathSelector(this=exp.JSONPathScript(this="@.x)")), ] self.assertEqual( - jsonpath.parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"), + parse("$.*.a[0]['x'][*, 'y', 1].z[?(@.a == 'b'), 1:][1:5][1,?@.a][(@.x)]"), exp.JSONPath(expressions=expected_expressions), ) @@ -36,7 +37,7 @@ class TestJsonpath(unittest.TestCase): ("$[((@.length-1))]", "$[((@.length-1))]"), ): with self.subTest(f"{selector} -> {expected}"): - self.assertEqual(jsonpath.parse(selector).sql(), f"'{expected}'") + self.assertEqual(parse(selector).sql(), f"'{expected}'") def test_cts_file(self): with open(os.path.join(FIXTURES_DIR, "jsonpath", "cts.json")) as file: @@ -131,9 +132,9 @@ class TestJsonpath(unittest.TestCase): with self.subTest(f"{selector.strip()} /* {test['name']} */"): if test.get("invalid_selector"): try: - jsonpath.parse(selector) + parse(selector) except (ParseError, TokenError): pass else: - path = jsonpath.parse(selector) + path = parse(selector) self.assertEqual(path.sql(), f"'{overrides.get(selector, selector)}'") |