-
-
Notifications
You must be signed in to change notification settings - Fork 6
Refactored test_lex.json to use test_lex.json for test case data. #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I understand the failing checks and will rectify them. |
Held up because my imports aren't pretty enough lol. Ok, I don't know what it wants me to do. I hit "Optimize Imports" in my IDE but that doesn't seem up to the task. Are there project guidelines for how it should be formatted? |
We use Ruff to lint and format all Python files. Among other things, Ruff enforces:
Ruff can be integrated with some editors. Personally I run it via Hatch on the command line, as illustrated in the new contributing guide. If you're working on a Hatch project, you'll probably want to install Hatch globally. I like to use pipx for this. |
4f93458
to
38a544e
Compare
Finally :) |
Hi @rob-ross, I think we can simplify it a bit by getting rid of the dataclass and not worry about mapping to token kinds defined in For example: import json
import operator
from typing import Any
from typing import Dict
import pytest
from jsonpath import DEFAULT_ENV
from jsonpath import JSONPathSyntaxError
from jsonpath.token import Token
with open("tests/test_lex.json", encoding="UTF-8") as fd:
CASES = json.load(fd)["tests"]
@pytest.mark.parametrize("case", CASES, ids=operator.itemgetter("description"))
def test_default_lexer(case: Dict[str, Any]) -> None:
tokens = list(DEFAULT_ENV.lexer.tokenize(case["path"]))
want = [Token(**token) for token in case["want"]]
assert tokens == want
def test_illegal_token() -> None:
with pytest.raises(JSONPathSyntaxError):
list(DEFAULT_ENV.lexer.tokenize("%")) No dataclass does means we'd get a What do you think? |
Sure. Looks fine. I'll work on that. |
38a544e
to
e433f8c
Compare
For my own repository, the standard workflow is to delete this branch after a successful merge to avoid confusion. Does this apply to a forked clone as well? I.e., should I delete this branch now? |
Yes, I would, as the branch is short-lived and you probably won't be coming back to it. |
Extracted the list of Case objects to the file test_lex.json. Updated test_lex.py to use the json file.