Skip to content

update error messages #792

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

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.1.0
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
Expand Down
31 changes: 18 additions & 13 deletions tests/test_core/test_vdom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest
from fastjsonschema import JsonSchemaException

Expand Down Expand Up @@ -213,6 +215,9 @@ def test_valid_vdom(value):
validate_vdom_json(value)


@pytest.mark.skipif(
sys.version_info < (3, 10), reason="error messages are different in Python<3.10"
)
@pytest.mark.parametrize(
"value, error_message_pattern",
[
Expand All @@ -230,34 +235,34 @@ def test_valid_vdom(value):
),
(
{"tagName": "tag", "children": None},
r"data must be array",
r"data\.children must be array",
),
(
{"tagName": "tag", "children": [None]},
r"data must be object or string",
r"data\.children\[{data_x}\] must be object or string",
),
(
{"tagName": "tag", "children": [{"tagName": None}]},
r"data\.tagName must be string",
r"data\.children\[{data_x}\]\.tagName must be string",
),
(
{"tagName": "tag", "attributes": None},
r"data.attributes must be object",
r"data\.attributes must be object",
),
(
{"tagName": "tag", "eventHandlers": None},
r"data must be object",
r"data\.eventHandlers must be object",
),
(
{"tagName": "tag", "eventHandlers": {"onEvent": None}},
r"data must be object",
r"data\.eventHandlers\.{data_key} must be object",
),
(
{
"tagName": "tag",
"eventHandlers": {"onEvent": {}},
},
r"data must contain \['target'\] properties",
r"data\.eventHandlers\.{data_key}\ must contain \['target'\] properties",
),
(
{
Expand All @@ -269,7 +274,7 @@ def test_valid_vdom(value):
}
},
},
r"data\.preventDefault must be boolean",
r"data\.eventHandlers\.{data_key}\.preventDefault must be boolean",
),
(
{
Expand All @@ -281,29 +286,29 @@ def test_valid_vdom(value):
}
},
},
r"data\.stopPropagation must be boolean",
r"data\.eventHandlers\.{data_key}\.stopPropagation must be boolean",
),
(
{"tagName": "tag", "importSource": None},
r"data must be object",
r"data\.importSource must be object",
),
(
{"tagName": "tag", "importSource": {}},
r"data must contain \['source'\] properties",
r"data\.importSource must contain \['source'\] properties",
),
(
{
"tagName": "tag",
"importSource": {"source": "something", "fallback": 0},
},
r"data\.fallback must be object or string or null",
r"data\.importSource\.fallback must be object or string or null",
),
(
{
"tagName": "tag",
"importSource": {"source": "something", "fallback": {"tagName": None}},
},
r"data.tagName must be string",
r"data\.importSource\.fallback\.tagName must be string",
),
],
)
Expand Down