mirror of
https://github.com/graphql-python/graphene.git
synced 2025-04-25 20:13:40 +03:00
fix assertion for badly formed JSON input on Python 3.13
This commit is contained in:
parent
393ff70701
commit
bc35e7f94e
|
@ -51,35 +51,30 @@ def test_jsonstring_invalid_query():
|
|||
Test that if an invalid type is provided we get an error
|
||||
"""
|
||||
result = schema.execute("{ json(input: 1) }")
|
||||
assert result.errors
|
||||
assert len(result.errors) == 1
|
||||
assert result.errors[0].message == "Expected value of type 'JSONString', found 1."
|
||||
assert result.errors == [
|
||||
{"message": "Expected value of type 'JSONString', found 1."},
|
||||
]
|
||||
|
||||
result = schema.execute("{ json(input: {}) }")
|
||||
assert result.errors
|
||||
assert len(result.errors) == 1
|
||||
assert result.errors[0].message == "Expected value of type 'JSONString', found {}."
|
||||
assert result.errors == [
|
||||
{"message": "Expected value of type 'JSONString', found {}."},
|
||||
]
|
||||
|
||||
result = schema.execute('{ json(input: "a") }')
|
||||
assert result.errors
|
||||
assert len(result.errors) == 1
|
||||
assert result.errors[0].message == (
|
||||
"Expected value of type 'JSONString', found \"a\"; "
|
||||
"Badly formed JSONString: Expecting value: line 1 column 1 (char 0)"
|
||||
)
|
||||
assert result.errors == [
|
||||
{
|
||||
"message": "Expected value of type 'JSONString', found \"a\"; "
|
||||
"Badly formed JSONString: Expecting value: line 1 column 1 (char 0)",
|
||||
},
|
||||
]
|
||||
|
||||
result = schema.execute("""{ json(input: "{\\'key\\': 0}") }""")
|
||||
assert result.errors
|
||||
assert len(result.errors) == 1
|
||||
assert (
|
||||
result.errors[0].message
|
||||
== "Syntax Error: Invalid character escape sequence: '\\''."
|
||||
)
|
||||
assert result.errors == [
|
||||
{"message": "Syntax Error: Invalid character escape sequence: '\\''."},
|
||||
]
|
||||
|
||||
result = schema.execute("""{ json(input: "{\\"key\\": 0,}") }""")
|
||||
assert result.errors
|
||||
assert len(result.errors) == 1
|
||||
assert result.errors[0].message == (
|
||||
'Expected value of type \'JSONString\', found "{\\"key\\": 0,}"; '
|
||||
"Badly formed JSONString: Expecting property name enclosed in double quotes: line 1 column 11 (char 10)"
|
||||
assert result.errors[0].message.startswith(
|
||||
'Expected value of type \'JSONString\', found "{\\"key\\": 0,}"; Badly formed JSONString:'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user