File: test_exceptions.py

package info (click to toggle)
jsonpath-ng 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 372 kB
  • sloc: python: 2,172; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest

from jsonpath_ng import parse as base_parse
from jsonpath_ng.exceptions import JsonPathParserError
from jsonpath_ng.ext import parse as ext_parse


@pytest.mark.parametrize(
    "path",
    (
        "foo[*.bar.baz",
        "foo.bar.`grandparent`.baz",
        "foo[*",
        # `len` extension not available in the base parser
        "foo.bar.`len`",
    ),
)
def test_rw_exception_subclass(path):
    with pytest.raises(JsonPathParserError):
        base_parse(path)


@pytest.mark.parametrize(
    "path",
    (
        "foo[*.bar.baz",
        "foo.bar.`grandparent`.baz",
        "foo[*",
    ),
)
def test_ext_exception_subclass(path):
    with pytest.raises(JsonPathParserError):
        ext_parse(path)