Skip to content
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

test_unexpected_data fails on Python 3.13 #55

Open
wRAR opened this issue Oct 6, 2024 · 1 comment · May be fixed by #56
Open

test_unexpected_data fails on Python 3.13 #55

wRAR opened this issue Oct 6, 2024 · 1 comment · May be fixed by #56
Assignees
Labels
bug Something isn't working

Comments

@wRAR
Copy link

wRAR commented Oct 6, 2024

3 tests fail with the same reason:

    def __test_invalid_input(data: str, msg: str, idx: int) -> None:
        with pytest.raises(sdjson.JSONDecodeError) as err:
                sdjson.loads(data)

        if PYPY:
                assert err.value.msg.startswith(msg)  # Fix for varying messages between PyPy versions
        else:
>               assert err.value.msg == msg
E     AssertionError: assert 'Illegal trai...end of object' == 'Expecting pr...double quotes'
E
E       - Expecting property name enclosed in double quotes
E       + Illegal trailing comma before end of object

Found in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082269 and I can confirm it locally.

@wRAR wRAR added the bug Something isn't working label Oct 6, 2024
@mcepl
Copy link

mcepl commented Oct 25, 2024

The same here on openSUSE:

[    6s] =================================== FAILURES ===================================
[    6s] ________________ test_unexpected_data[[42,]-Expecting value-4] _________________
[    6s] 
[    6s] data = '[42,]', msg = 'Expecting value', idx = 4
[    6s] 
[    6s]     @pytest.mark.parametrize(
[    6s]     		"data, msg, idx",
[    6s]     		[
[    6s]     				("[,", "Unexpected ','" if PYPY else "Expecting value", 1),
[    6s]     				('{"spam":[}', unexpected_right_brace, 9),
[    6s]     				("[42:", unexpected_colon, 3),
[    6s]     				('[42 "spam"', "Unexpected '\"' when decoding array" if PYPY else "Expecting ',' delimiter", 4),
[    6s]     				("[42,]", "Unexpected ']'" if PYPY else "Expecting value", 4),
[    6s]     				('{"spam":[42}', "Unexpected '}' when decoding array" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('["]', "Unterminated string starting at", 1),
[    6s]     				('["spam":', unexpected_colon, 7),
[    6s]     				('["spam",]', "Unexpected ']'" if PYPY else "Expecting value", 8),
[    6s]     				("{:", property_name_string, 1),
[    6s]     				("{,", property_name_string, 1),
[    6s]     				("{42", property_name_string, 1),
[    6s]     				("[{]", property_name_string, 2),
[    6s]     				('{"spam",', missing_colon, 7),
[    6s]     				('{"spam"}', missing_colon, 7),
[    6s]     				('[{"spam"]', missing_colon, 8),
[    6s]     				('{"spam":}', unexpected_right_brace, 8),
[    6s]     				('[{"spam":]', "Unexpected ']'" if PYPY else "Expecting value", 9),
[    6s]     				(
[    6s]     						'{"spam":42 "ham"',
[    6s]     						"Unexpected '\"' when decoding object" if PYPY else "Expecting ',' delimiter",
[    6s]     						11
[    6s]     						),
[    6s]     				('[{"spam":42]', "Unexpected ']' when decoding object" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('{"spam":42,}', property_name_string, 11),
[    6s]     				]
[    6s]     		)
[    6s]     def test_unexpected_data(data: str, msg: str, idx: int):
[    6s] >   	__test_invalid_input(data, msg, idx)
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:189: 
[    6s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    6s] 
[    6s] data = '[42,]', msg = 'Expecting value', idx = 4
[    6s] 
[    6s]     def __test_invalid_input(data: str, msg: str, idx: int) -> None:
[    6s]     	with pytest.raises(sdjson.JSONDecodeError) as err:
[    6s]     		sdjson.loads(data)
[    6s]     
[    6s]     	if PYPY:
[    6s]     		assert err.value.msg.startswith(msg)  # Fix for varying messages between PyPy versions
[    6s]     	else:
[    6s] >   		assert err.value.msg == msg
[    6s] E     AssertionError: assert 'Illegal trai... end of array' == 'Expecting value'
[    6s] E       
[    6s] E       - Expecting value
[    6s] E       + Illegal trailing comma before end of array
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:116: AssertionError
[    6s] ______________ test_unexpected_data[["spam",]-Expecting value-8] _______________
[    6s] 
[    6s] data = '["spam",]', msg = 'Expecting value', idx = 8
[    6s] 
[    6s]     @pytest.mark.parametrize(
[    6s]     		"data, msg, idx",
[    6s]     		[
[    6s]     				("[,", "Unexpected ','" if PYPY else "Expecting value", 1),
[    6s]     				('{"spam":[}', unexpected_right_brace, 9),
[    6s]     				("[42:", unexpected_colon, 3),
[    6s]     				('[42 "spam"', "Unexpected '\"' when decoding array" if PYPY else "Expecting ',' delimiter", 4),
[    6s]     				("[42,]", "Unexpected ']'" if PYPY else "Expecting value", 4),
[    6s]     				('{"spam":[42}', "Unexpected '}' when decoding array" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('["]', "Unterminated string starting at", 1),
[    6s]     				('["spam":', unexpected_colon, 7),
[    6s]     				('["spam",]', "Unexpected ']'" if PYPY else "Expecting value", 8),
[    6s]     				("{:", property_name_string, 1),
[    6s]     				("{,", property_name_string, 1),
[    6s]     				("{42", property_name_string, 1),
[    6s]     				("[{]", property_name_string, 2),
[    6s]     				('{"spam",', missing_colon, 7),
[    6s]     				('{"spam"}', missing_colon, 7),
[    6s]     				('[{"spam"]', missing_colon, 8),
[    6s]     				('{"spam":}', unexpected_right_brace, 8),
[    6s]     				('[{"spam":]', "Unexpected ']'" if PYPY else "Expecting value", 9),
[    6s]     				(
[    6s]     						'{"spam":42 "ham"',
[    6s]     						"Unexpected '\"' when decoding object" if PYPY else "Expecting ',' delimiter",
[    6s]     						11
[    6s]     						),
[    6s]     				('[{"spam":42]', "Unexpected ']' when decoding object" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('{"spam":42,}', property_name_string, 11),
[    6s]     				]
[    6s]     		)
[    6s]     def test_unexpected_data(data: str, msg: str, idx: int):
[    6s] >   	__test_invalid_input(data, msg, idx)
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:189: 
[    6s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    6s] 
[    6s] data = '["spam",]', msg = 'Expecting value', idx = 8
[    6s] 
[    6s]     def __test_invalid_input(data: str, msg: str, idx: int) -> None:
[    6s]     	with pytest.raises(sdjson.JSONDecodeError) as err:
[    6s]     		sdjson.loads(data)
[    6s]     
[    6s]     	if PYPY:
[    6s]     		assert err.value.msg.startswith(msg)  # Fix for varying messages between PyPy versions
[    6s]     	else:
[    6s] >   		assert err.value.msg == msg
[    6s] E     AssertionError: assert 'Illegal trai... end of array' == 'Expecting value'
[    6s] E       
[    6s] E       - Expecting value
[    6s] E       + Illegal trailing comma before end of array
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:116: AssertionError
[    6s] _ test_unexpected_data[{"spam":42,}-Expecting property name enclosed in double quotes-11] _
[    6s] 
[    6s] data = '{"spam":42,}', msg = 'Expecting property name enclosed in double quotes'
[    6s] idx = 11
[    6s] 
[    6s]     @pytest.mark.parametrize(
[    6s]     		"data, msg, idx",
[    6s]     		[
[    6s]     				("[,", "Unexpected ','" if PYPY else "Expecting value", 1),
[    6s]     				('{"spam":[}', unexpected_right_brace, 9),
[    6s]     				("[42:", unexpected_colon, 3),
[    6s]     				('[42 "spam"', "Unexpected '\"' when decoding array" if PYPY else "Expecting ',' delimiter", 4),
[    6s]     				("[42,]", "Unexpected ']'" if PYPY else "Expecting value", 4),
[    6s]     				('{"spam":[42}', "Unexpected '}' when decoding array" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('["]', "Unterminated string starting at", 1),
[    6s]     				('["spam":', unexpected_colon, 7),
[    6s]     				('["spam",]', "Unexpected ']'" if PYPY else "Expecting value", 8),
[    6s]     				("{:", property_name_string, 1),
[    6s]     				("{,", property_name_string, 1),
[    6s]     				("{42", property_name_string, 1),
[    6s]     				("[{]", property_name_string, 2),
[    6s]     				('{"spam",', missing_colon, 7),
[    6s]     				('{"spam"}', missing_colon, 7),
[    6s]     				('[{"spam"]', missing_colon, 8),
[    6s]     				('{"spam":}', unexpected_right_brace, 8),
[    6s]     				('[{"spam":]', "Unexpected ']'" if PYPY else "Expecting value", 9),
[    6s]     				(
[    6s]     						'{"spam":42 "ham"',
[    6s]     						"Unexpected '\"' when decoding object" if PYPY else "Expecting ',' delimiter",
[    6s]     						11
[    6s]     						),
[    6s]     				('[{"spam":42]', "Unexpected ']' when decoding object" if PYPY else "Expecting ',' delimiter", 11),
[    6s]     				('{"spam":42,}', property_name_string, 11),
[    6s]     				]
[    6s]     		)
[    6s]     def test_unexpected_data(data: str, msg: str, idx: int):
[    6s] >   	__test_invalid_input(data, msg, idx)
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:189: 
[    6s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    6s] 
[    6s] data = '{"spam":42,}', msg = 'Expecting property name enclosed in double quotes'
[    6s] idx = 11
[    6s] 
[    6s]     def __test_invalid_input(data: str, msg: str, idx: int) -> None:
[    6s]     	with pytest.raises(sdjson.JSONDecodeError) as err:
[    6s]     		sdjson.loads(data)
[    6s]     
[    6s]     	if PYPY:
[    6s]     		assert err.value.msg.startswith(msg)  # Fix for varying messages between PyPy versions
[    6s]     	else:
[    6s] >   		assert err.value.msg == msg
[    6s] E     AssertionError: assert 'Illegal trai...end of object' == 'Expecting pr...double quotes'
[    6s] E       
[    6s] E       - Expecting property name enclosed in double quotes
[    6s] E       + Illegal trailing comma before end of object
[    6s] 
[    6s] tests/stdlib_tests/test_fail.py:116: AssertionError
[    6s] ============================= slowest 25 durations =============================
[    6s] 0.06s call     tests/stdlib_tests/test_unicode.py::test_unicode_decode
[    6s] 0.06s call     tests/stdlib_tests/test_recursion.py::test_highly_nested_objects_encoding
[    6s] 
[    6s] (23 durations < 0.005s hidden.  Use -vv to show these durations.)
[    6s] =========================== short test summary info ============================
[    6s] FAILED tests/stdlib_tests/test_fail.py::test_unexpected_data[[42,]-Expecting value-4] - AssertionError: assert 'Illegal trai... end of array' == 'Expecting value'
[    6s] FAILED tests/stdlib_tests/test_fail.py::test_unexpected_data[["spam",]-Expecting value-8] - AssertionError: assert 'Illegal trai... end of array' == 'Expecting value'
[    6s] FAILED tests/stdlib_tests/test_fail.py::test_unexpected_data[{"spam":42,}-Expecting property name enclosed in double quotes-11] - AssertionError: assert 'Illegal trai...end of object' == 'Expecting pr...do...
[    6s] =================== 3 failed, 148 passed, 4 xfailed in 0.40s ===================

Complete build log with the record of all packages used and steps taken to reproduce.

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Nov 8, 2024
cjwatson added a commit to cjwatson/singledispatch-json that referenced this issue Nov 13, 2024
The previously-expected messages and indexes were changed by
python/cpython#113227.

Fixes: domdfcoding#55
@cjwatson cjwatson linked a pull request Nov 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants