import hypothesis.strategies as st
from hypothesis import assume, given
from hypothesis.extra.lark import from_lark
import json
from contextlib import suppress
from lark import Lark
json_grammar = Lark(
r"""
value: dict
| list
| ESCAPED_STRING
| SIGNED_NUMBER
| "true" | "false" | "null"
list : "[" [value ("," value)*] "]"
dict : "{" [pair ("," pair)*] "}"
pair : ESCAPED_STRING ":" value
%import common.ESCAPED_STRING
%import common.SIGNED_NUMBER
%import common.WS
%ignore WS
""",
start="value",
)
@given(st.one_of(st.text(), from_lark(json_grammar)))
def test_json(text):
with suppress(json.JSONDecodeError):
json.loads(text)
json_ground_values = st.one_of(
st.text(), st.booleans(), st.integers(), st.floats(allow_nan=False)
)
json_data = st.recursive(
json_ground_values, lambda x: st.one_of(st.lists(x), st.dictionaries(st.text(), x))
)
@given(json_data)
def test_json_roundtrip(data):
assert json.loads(json.dumps(data)) == data
Process Process-1:
Exception in thread Thread-3:
Traceback (most recent call last):
File "...lib/python3.12/site-packages/hypofuzz/dashboard/dashboard.py", line 364, in send_nowait_from_anywhere
+ Exception Group Traceback (most recent call last):
| File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
| self.run()
| File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
| self._target(*self._args, **self._kwargs)
| File "...lib/python3.12/site-packages/hypofuzz/dashboard/dashboard.py", line 419, in start_dashboard_process
| trio.run(run_dashboard, port, host)
| File "...lib/python3.12/site-packages/trio/_core/_run.py", line 2547, in run
| raise runner.main_task_outcome.error
| File "...lib/python3.12/site-packages/hypofuzz/dashboard/dashboard.py", line 380, in run_dashboard
| async with trio.open_nursery() as nursery:
| File "...lib/python3.12/site-packages/trio/_core/_run.py", line 1125, in __aexit__
| raise combined_error_from_nursery
| ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "...lib/python3.12/site-packages/hypofuzz/dashboard/dashboard.py", line 242, in handle_event
| event = _dashboard_event(db_event)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "...lib/python3.12/site-packages/hypofuzz/dashboard/dashboard.py", line 117, in _dashboard_event
| TESTS[value.nodeid].add_report(value)
| File "...lib/python3.12/site-packages/hypofuzz/dashboard/test.py", line 139, in add_report
| linear_report = ReportWithDiff.from_reports(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "...lib/python3.12/site-packages/hypofuzz/database/models.py", line 281, in from_reports
| return cls(
| ^^^^
| File "<string>", line 16, in __init__
| File "...lib/python3.12/site-packages/hypofuzz/database/models.py", line 244, in __post_init__
| assert all(
| ^^^^
trio.lowlevel.current_task()
File "...lib/python3.12/site-packages/trio/_core/_ run.py", line 2991, in current_task
| AssertionError: {Status.OVERRUN: -2, Status.INVALID: 0, Status.VALID: 257, Status.INTERESTING: 0}
I tried to create a small example that tests the json module:
It seems to work for a while, but then I get the following crash:
I have tried deleting the
.hypothesisdirectory but it seems to not help. hypofuzz version 25.11.1, hypothesis version 6.142.1