repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
caronc/apprise-api
import json from unittest.mock import patch from django.test import SimpleTestCase, override_settings from django.urls import Resolver404, resolve class ManagerPageTests(SimpleTestCase): @override_settings(APPRISE_API_ONLY=True) def test_api_only_blocks_config_list_if_present(self) -> None: """ ...
421
assert
numeric_literal
apprise_api/api/tests/test_manager.py
test_api_only_blocks_config_list_if_present
ManagerPageTests
184
null
caronc/apprise-api
import os import tempfile from unittest import mock from django.test import SimpleTestCase from .. import utils class UtilsTests(SimpleTestCase): def test_touchdir(self): """ Test touchdir() """ with tempfile.TemporaryDirectory() as tmpdir: with mock.patch("os.makedir...
True
assert
bool_literal
apprise_api/api/tests/test_utils.py
test_touchdir
UtilsTests
47
null
caronc/apprise-api
import errno import os from unittest.mock import mock_open, patch from apprise import ConfigFormat from ..utils import AppriseConfigCache, AppriseStoreMode, SimpleFileExtension def test_apprise_config_list_simple_mode(tmpdir): """ Test Apprise Config Keys List using SIMPLE mode """ # Create our objec...
10
assert
numeric_literal
apprise_api/api/tests/test_config_cache.py
test_apprise_config_list_simple_mode
149
null
caronc/apprise-api
import inspect from json import dumps import os import re from unittest.mock import Mock, patch from django.test import SimpleTestCase from django.test.utils import override_settings import requests import apprise from ..forms import NotifyForm from ..utils import ConfigCache N_MGR = apprise.manager_plugins.Notific...
2
assert
numeric_literal
apprise_api/api/tests/test_stateful_notify.py
test_stateful_group_dict_notify
StatefulNotifyTests
419
null
caronc/apprise-api
import base64 from contextlib import suppress from os.path import dirname, getsize, join from shutil import rmtree from tempfile import TemporaryDirectory from unittest import mock from unittest.mock import mock_open, patch from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile ...
"web"
assert
string_literal
apprise_api/api/tests/test_attachment.py
test_attachment_initialization
AttachmentTests
84
null
caronc/apprise-api
from django.test import SimpleTestCase from ..urlfilter import AppriseURLFilter class AttachmentTests(SimpleTestCase): def test_apprise_url_filter(self): """ Test the apprise url filter """ # empty allow and deny lists af = AppriseURLFilter("", "") # Test garbage e...
af.is_allowed(42))
self.assertFalse
func_call
apprise_api/api/tests/test_urlfilter.py
test_apprise_url_filter
AttachmentTests
44
null
caronc/apprise-api
from django.test import SimpleTestCase class ErrorTests(SimpleTestCase): def test_get_421(self): """ Test 421 """ response = self.client.get("/_/421") assert response.status_code ==
421
assert
numeric_literal
apprise_api/error/tests/test_errors.py
test_get_421
ErrorTests
41
null
caronc/apprise-api
import hashlib import json from unittest import mock from unittest.mock import patch from django.core.exceptions import RequestDataTooBig from django.test import SimpleTestCase from django.test.utils import override_settings from apprise import ConfigFormat from ..forms import AUTO_DETECT_CONFIG_KEYWORD class AddTe...
200
assert
numeric_literal
apprise_api/api/tests/test_add.py
test_key_lengths
AddTests
61
null
caronc/apprise-api
from unittest.mock import patch from django.test import SimpleTestCase class GetTests(SimpleTestCase): def test_get_config(self): """ Test retrieving configuration """ # our key to use key = "test_get_config_" # GET returns 405 (not allowed) response = se...
200
assert
numeric_literal
apprise_api/api/tests/test_get.py
test_get_config
GetTests
55
null
caronc/apprise-api
import errno import os from unittest.mock import mock_open, patch from apprise import ConfigFormat from ..utils import AppriseConfigCache, AppriseStoreMode, SimpleFileExtension def test_apprise_config_io_hash_mode(tmpdir): """ Test Apprise Config Disk Put/Get using HASH mode """ content = "mailto://t...
None
assert
none_literal
apprise_api/api/tests/test_config_cache.py
test_apprise_config_io_hash_mode
78
null
caronc/apprise-api
from django.test import SimpleTestCase from ..payload_mapper import remap_fields class NotifyPayloadMapper(SimpleTestCase): def test_remap_fields(self): """ Test payload re-mapper """ # # No rules defined # rules = {} payload = { "forma...
{ "format": "markdown", "body": "body", }
assert
collection
apprise_api/api/tests/test_payload_mapper.py
test_remap_fields
NotifyPayloadMapper
169
null
caronc/apprise-api
import hashlib import json from unittest import mock from unittest.mock import patch from django.core.exceptions import RequestDataTooBig from django.test import SimpleTestCase from django.test.utils import override_settings from apprise import ConfigFormat from ..forms import AUTO_DETECT_CONFIG_KEYWORD class AddTe...
128
assert
numeric_literal
apprise_api/api/tests/test_add.py
test_key_lengths
AddTests
57
null
caronc/apprise-api
import errno import os from unittest.mock import mock_open, patch from apprise import ConfigFormat from ..utils import AppriseConfigCache, AppriseStoreMode, SimpleFileExtension def test_apprise_config_list_simple_mode(tmpdir): """ Test Apprise Config Keys List using SIMPLE mode """ # Create our objec...
sorted(text_keys + yaml_keys)
assert
func_call
apprise_api/api/tests/test_config_cache.py
test_apprise_config_list_simple_mode
150
null
caronc/apprise-api
import errno import os from unittest.mock import mock_open, patch from apprise import ConfigFormat from ..utils import AppriseConfigCache, AppriseStoreMode, SimpleFileExtension def test_apprise_config_list_simple_mode(tmpdir): """ Test Apprise Config Keys List using SIMPLE mode """ # Create our objec...
11
assert
numeric_literal
apprise_api/api/tests/test_config_cache.py
test_apprise_config_list_simple_mode
146
null
caronc/apprise-api
from unittest.mock import patch from django.test import SimpleTestCase from django.test.utils import override_settings class JsonUrlsTests(SimpleTestCase): def test_json_urls_config(self): """ Test retrieving configuration """ # our key to use key = "test_json_urls_config...
0
assert
numeric_literal
apprise_api/api/tests/test_json_urls.py
test_json_urls_config
JsonUrlsTests
90
null
caronc/apprise-api
from json import loads from unittest import mock from django.test import SimpleTestCase from django.test.utils import override_settings from ..utils import healthcheck class HealthCheckTests(SimpleTestCase): def test_healthcheck_simple(self): """ Test retrieving basic successful health-checks ...
200)
self.assertEqual
numeric_literal
apprise_api/api/tests/test_healthecheck.py
test_healthcheck_simple
HealthCheckTests
49
null
caronc/apprise-api
from django.test import SimpleTestCase from ..payload_mapper import remap_fields class NotifyPayloadMapper(SimpleTestCase): def test_remap_fields(self): """ Test payload re-mapper """ # # No rules defined # rules = {} payload = { "forma...
{ "format": "markdown", "body": "the message", }
assert
collection
apprise_api/api/tests/test_payload_mapper.py
test_remap_fields
NotifyPayloadMapper
192
null
caronc/apprise-api
from django.test import SimpleTestCase class ErrorTests(SimpleTestCase): def test_get_50x(self): """ Test 50x """ response = self.client.get("/_/50x") assert response.status_code ==
500
assert
numeric_literal
apprise_api/error/tests/test_errors.py
test_get_50x
ErrorTests
48
null
caronc/apprise-api
import json from unittest.mock import patch from django.test import SimpleTestCase, override_settings from django.urls import Resolver404, resolve class ManagerPageTests(SimpleTestCase): def test_manage_status_code(self): """ General testing of management page """ # No permission ...
404
assert
numeric_literal
apprise_api/api/tests/test_manager.py
test_manage_status_code
ManagerPageTests
67
null
caronc/apprise-api
from json import loads from unittest import mock from django.test import SimpleTestCase from django.test.utils import override_settings from ..utils import healthcheck class HealthCheckTests(SimpleTestCase): def test_post_not_supported(self): """ Test POST requests """ response = ...
405
assert
numeric_literal
apprise_api/api/tests/test_healthecheck.py
test_post_not_supported
HealthCheckTests
40
null
caronc/apprise-api
import errno import os from unittest.mock import mock_open, patch from apprise import ConfigFormat from ..utils import AppriseConfigCache, AppriseStoreMode, SimpleFileExtension def test_apprise_config_io_disabled_mode(tmpdir): """ Test Apprise Config Disk Put/Get using DISABLED mode """ content = "ma...
AppriseStoreMode.DISABLED
assert
complex_expr
apprise_api/api/tests/test_config_cache.py
test_apprise_config_io_disabled_mode
284
null
caronc/apprise-api
import hashlib from unittest.mock import patch from django.test import SimpleTestCase from django.test.utils import override_settings class DelTests(SimpleTestCase): def test_key_lengths(self): """ Test our key lengths """ # our key to use h = hashlib.sha512() h.u...
128
assert
numeric_literal
apprise_api/api/tests/test_del.py
test_key_lengths
DelTests
50
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number_edge_cases(): assert ( repair_json(' - { "test_key": ["test_value", "test_value2"] }') == '{"test_key": ["test_value", "test_value2"]}' ) assert repair_json('{"key": 1/3}') == '{"key": "1/3"}' assert repair_json('{"key":...
'{"key": 0.25}'
assert
string_literal
tests/test_parse_number.py
test_parse_number_edge_cases
16
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json from src.json_repair.json_parser import JSONParser from src.json_repair.schema_repair import SchemaRepairer from src.json_repair.utils.json_context import ContextValues def parse_object_direct(raw, schema, *, strict=False, context=None): parser = JSONParser(ra...
[1]
assert
collection
tests/test_schema_parser_paths.py
test_parse_array_schema_true_false_and_non_array
139
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_pydantic_v2_defaults(): pydantic = pytest.importorskip("pydantic") version = getattr(pydantic, "...
{"evidence_types": []}
assert
collection
tests/test_schema_guided_parse.py
test_schema_pydantic_v2_defaults
122
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number(): assert repair_json("1", return_objects=True) == 1 assert repair_json("1.2", return_objects=True) == 1.2 assert repair_json('{"value": 82_461_110}', return_objects=True) == {"value": 82461110} assert repair_json('{"value": 1_2...
{"value": 1234.56}
assert
collection
tests/test_parse_number.py
test_parse_number
8
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
""
assert
string_literal
tests/test_schema_repairer.py
test_normalize_missing_values_nested_and_invalid
22
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_slice_variations(tmp_path): file_path = tmp_path / "slice.json" file_path.write_text("abcd", encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: wrapper = StringFi...
"abc"
assert
string_literal
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_slice_variations
36
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object(): assert repair_json("{}", return_objects=True) ==
{}
assert
collection
tests/test_parse_object.py
test_parse_object
5
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_detects_immediate_doubled_quotes(): with pytest.raises(
ValueError, match="doubled quotes followed by another quote\\.$")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_detects_immediate_doubled_quotes
40
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_rejects_invalid_schema_type(client): response = client.post( "/api/repair-json", json={"malformedJSON": ...
{"error": "schema must be a JSON object or boolean."}
assert
collection
tests/test_docs_app_schema.py
test_docs_api_rejects_invalid_schema_type
65
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json from src.json_repair.json_parser import JSONParser from src.json_repair.schema_repair import SchemaRepairer from src.json_repair.utils.json_context import ContextValues def parse_object_direct(raw, schema, *, strict=False, context=None): parser = JSONParser(ra...
""
assert
string_literal
tests/test_schema_parser_paths.py
test_parse_json_with_schema_branches
195
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number_edge_cases(): assert ( repair_json(' - { "test_key": ["test_value", "test_value2"] }') == '{"test_key": ["test_value", "test_value2"]}' ) assert repair_json('{"key": 1/3}') == '{"key": "1/3"}' assert repair_json('{"key": ...
"[105, 12]"
assert
string_literal
tests/test_parse_number.py
test_parse_number_edge_cases
19
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
"x"
assert
string_literal
tests/test_schema_repairer.py
test_schema_from_input_model_defaults_and_required
87
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number_edge_cases(): assert ( repair_json(' - { "test_key": ["test_value", "test_value2"] }') == '{"test_key": ["test_value", "test_value2"]}' ) assert repair_json('{"key": 1/3}') == '{"key": "1/3"}' assert repair_json('{"key": ...
'{"key": 1.0}'
assert
string_literal
tests/test_parse_number.py
test_parse_number_edge_cases
25
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
[]
assert
collection
tests/test_schema_repairer.py
test_repair_object_and_array_paths
337
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_edge_cases(): assert repair_json("{foo: [}") == '{"foo": []}' assert repair_json('{"": "value"') == '{"": "value"}' assert repair_json('{"key": "v"alue"}') == '{"key": "v\\"alue\\""}' assert repair_json('{"value_1": true, COMMENT...
'{"key": "value"}'
assert
string_literal
tests/test_parse_object.py
test_parse_object_edge_cases
66
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_multiple_jsons(): assert repair_json("[]{}") == "[]" assert repair_json('[]{"key":"value"}') ==
'{"key": "value"}'
assert
string_literal
tests/test_json_repair.py
test_multiple_jsons
22
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_valid_json(): assert ( repair_json('{"name": "John", "age": 30, "city": "New York"}') == '{"name": "John", "age": 30, "city": "New York"}' ) assert repair_json('{"employees":["John", "Anna", "Peter"]} ') == '{"employees": [...
'{"key": "value\\nvalue"}'
assert
string_literal
tests/test_json_repair.py
test_valid_json
17
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_duplicate_keys_inside_array(): payload = '[{"key": "first", "key": "second"}]' with pytest.raises(
ValueError, match="Duplicate key found")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_duplicate_keys_inside_array
13
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_applies_to_valid_json_without_skip_json_loads(): pytest.importorskip("jsonschema") schema = { ...
{"value": 1}
assert
collection
tests/test_schema_guided_parse.py
test_schema_applies_to_valid_json_without_skip_json_loads
70
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_salvage_mode_maps_list_to_object_when_unambiguous(): pytest.importorskip("jsonschema") schema = ...
ValueError, match="Expected object")
pytest.raises
complex_expr
tests/test_schema_guided_parse.py
test_schema_salvage_mode_maps_list_to_object_when_unambiguous
254
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
2
assert
numeric_literal
tests/test_schema_repairer.py
test_repair_value_missing_and_unions
224
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_rejects_empty_keys(): payload = '{"" : "value"}' with pytest.raises(
ValueError, match="Empty key found")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_rejects_empty_keys
19
null
mangiucugna/json_repair
import os import pathlib import tempfile from src.json_repair.json_repair import from_file def test_repair_json_from_file(): path = pathlib.Path(__file__).parent.resolve() # Use chunk_length 2 to test the buffering feature assert from_file(filename=path / "invalid.json") == [ { "_id":...
("", [])
assert
collection
tests/test_repair_json_from_file.py
test_repair_json_from_file
491
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_array(): assert repair_json("[]", return_objects=True) ==
[]
assert
collection
tests/test_parse_array.py
test_parse_array
5
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
1
assert
numeric_literal
tests/test_schema_repairer.py
test_schema_from_input_non_dict_properties
126
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_string(): assert repair_json('"') ==
""
assert
string_literal
tests/test_parse_string.py
test_parse_string
5
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_edge_cases(): assert repair_json("{foo: [}") == '{"foo": []}' assert repair_json('{"": "value"') == '{"": "value"}' assert repair_json('{"key": "v"alue"}') == '{"key": "v\\"alue\\""}' assert repair_json('{"value_1": true, COMMENT...
'{"a": "{ b"}'
assert
string_literal
tests/test_parse_object.py
test_parse_object_edge_cases
45
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_applies_to_valid_json_fast_path_outputs_and_logging(): pytest.importorskip("jsonschema") schema ...
'{"value": 1}'
assert
string_literal
tests/test_schema_guided_parse.py
test_schema_applies_to_valid_json_fast_path_outputs_and_logging
97
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_ensure_ascii(): assert repair_json("{'test_中国人_ascii':'统一码'}", ensure_ascii=False) == '{"test_中国人_
'{"test_中国人_ascii": "统一码"}'
assert
string_literal
tests/test_json_repair.py
test_ensure_ascii
143
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
0
assert
numeric_literal
tests/test_schema_repairer.py
test_fill_missing_and_coerce_scalar_paths
357
null
mangiucugna/json_repair
import copy from typing import Any, ClassVar import pytest from src.json_repair import repair_json from src.json_repair.schema_repair import ( SchemaRepairer, load_schema_model, normalize_missing_values, normalize_schema_repair_mode, schema_from_input, ) from src.json_repair.utils.constants import...
[1]
assert
collection
tests/test_schema_repairer.py
test_repair_object_and_array_paths
293
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_slice_variations(tmp_path): file_path = tmp_path / "slice.json" file_path.write_text("abcd", encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: wrapper = StringFi...
ValueError, match="slice step cannot be zero")
pytest.raises
complex_expr
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_slice_variations
39
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number(): assert repair_json("1", return_objects=True) ==
1
assert
numeric_literal
tests/test_parse_number.py
test_parse_number
5
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_valid_json(): assert ( repair_json('{"name": "John", "age": 30, "city": "New York"}') == '{"name": "John", "age": 30, "city": "New York"}' ) assert repair_json('{"employees":["John", "Anna", "Peter"]} ') == '{"employees": [...
'{"key": "value\\u263a"}'
assert
string_literal
tests/test_json_repair.py
test_valid_json
16
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_handles_multibyte(tmp_path): text = "\u0800" file_path = tmp_path / "multibyte.json" file_path.write_text(text, encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: ...
text
assert
variable
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_handles_multibyte
12
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_rejects_salvage_mode_without_schema(client): response = client.post( "/api/repair-json", json={"malforme...
{"error": "schemaRepairMode='salvage' requires schema."}
assert
collection
tests/test_docs_app_schema.py
test_docs_api_rejects_salvage_mode_without_schema
112
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_valid_json(): assert ( repair_json('{"name": "John", "age": 30, "city": "New York"}') == '{"name": "John", "age": 30, "city": "New York"}' ) assert repair_json('{"employees":["John", "Anna", "Peter"]} ') == '{"employees": [...
'{"key1": {"key2": [1, 2, 3]}}'
assert
string_literal
tests/test_json_repair.py
test_valid_json
14
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_valid_json(): assert ( repair_json('{"name": "John", "age": 30, "city": "New York"}') == '{"name": "John", "age": 30, "city": "New York"}' ) assert repair_json('{"employees":["John", "Anna", "Peter"]} ') == '{"employees": [...
'{"key": "value:value"}'
assert
string_literal
tests/test_json_repair.py
test_valid_json
10
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_repair_json_with_objects(): # Test with valid JSON strings assert repair_json("[]", return_objects=True) == [] assert repair_json("{}", return_objects=True) ==
{}
assert
collection
tests/test_json_repair.py
test_repair_json_with_objects
34
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_rejects_empty_values(): payload = '{"key": , "key2": "value2"}' with pytest.raises(
ValueError, match="Parsed value is empty")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_rejects_empty_values
30
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_optional_default_is_inserted(): pytest.importorskip("jsonschema") schema = { "type": "ob...
{"note": "n/a"}
assert
collection
tests/test_schema_guided_parse.py
test_schema_optional_default_is_inserted
54
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_schema_validation_error_returns_400(client): pytest.importorskip("jsonschema") response = client.post( "/api...
payload["error"]
assert
complex_expr
tests/test_docs_app_schema.py
test_docs_api_schema_validation_error_returns_400
82
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_missing_and_mixed_quotes(): assert ( repair_json("{'key': 'string', 'key2': false, \"key3\": null, \"key4\": unquoted}") == '{"key": "string", "key2": false, "key3": null, "key4": "unquoted"}' ) assert ( repair_json('{"nam...
'{"key": "value"}'
assert
string_literal
tests/test_parse_string.py
test_missing_and_mixed_quotes
44
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_merge_at_the_end(): assert repair_json('{"key": "value"}, "key2": "value2"}') == '{"key": "value", "key2": "value2"}' assert repair_json('{"key": "value"}, "key2": }') == '{"key": "value", "key2": ""}' assert repair_json('{"key": "va...
'[{"key": "value"}, ["abc"]]'
assert
string_literal
tests/test_parse_object.py
test_parse_object_merge_at_the_end
102
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_array_missing_quotes(): assert repair_json('["value1" value2", "value3"]') == '["value1", "value2", "value3"]' assert
'{"bad_one": ["Lorem Ipsum", "consectetur", "comment"], "good_one": ["elit", "sed", "tempor"]}'
assert
string_literal
tests/test_parse_array.py
test_parse_array_missing_quotes
54
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_salvage_mode_drops_invalid_array_items(client): pytest.importorskip("jsonschema") schema = { "type": "object...
{"items": [{"id": 1, "score": 85.6}]}
assert
collection
tests/test_docs_app_schema.py
test_docs_api_salvage_mode_drops_invalid_array_items
147
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_salvage_mode_drops_invalid_array_items(): pytest.importorskip("jsonschema") schema = { "...
ValueError, match="Expected number")
pytest.raises
complex_expr
tests/test_schema_guided_parse.py
test_schema_salvage_mode_drops_invalid_array_items
188
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_valid_fast_path_keeps_logging_empty(): pytest.importorskip("jsonschema") schema = { "typ...
[]
assert
collection
tests/test_schema_guided_parse.py
test_schema_valid_fast_path_keeps_logging_empty
87
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_applies_to_valid_json_without_skip_json_loads(): pytest.importorskip("jsonschema") schema = { ...
""
assert
string_literal
tests/test_schema_guided_parse.py
test_schema_applies_to_valid_json_without_skip_json_loads
72
null
mangiucugna/json_repair
import io import json import os import tempfile from pathlib import Path from unittest.mock import patch import pytest from src.json_repair.json_repair import cli def test_cli(capsys): # Create a temporary file temp_fd, temp_path = tempfile.mkstemp(suffix=".json") _, tempout_path = tempfile.mkstemp(suffi...
'{\n"key": "value"\n}'
assert
string_literal
tests/test_repair_json_cli.py
test_cli
31
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_negative_indices(tmp_path): file_path = tmp_path / "index.json" file_path.write_text("xyz", encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: wrapper = StringFil...
"z"
assert
string_literal
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_negative_indices
48
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_repair_json_with_objects(): # Test with valid JSON strings assert repair_json("[]", return_objects=True) ==
[]
assert
collection
tests/test_json_repair.py
test_repair_json_with_objects
33
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_missing_and_mixed_quotes(): assert ( repair_json("{'key': 'string', 'key2': false, \"key3\": null, \"key4\": unquoted}") == '{"key": "string", "key2": false, "key3": null, "key4": "unquoted"}' ) assert ( repair_json('{"nam...
'{" key": "val"}'
assert
string_literal
tests/test_parse_string.py
test_missing_and_mixed_quotes
47
null
mangiucugna/json_repair
from src.json_repair.json_repair import loads, repair_json def test_stream_stable(): # default: stream_stable = False # When the json to be repaired is the accumulation of streaming json at a certain moment. # The default repair result is unstable. assert repair_json('{"key": "val\\', stream_stable=Fal...
'{"key": "val\\n"}'
assert
string_literal
tests/test_json_repair.py
test_stream_stable
158
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_schema_validation_error_returns_400(client): pytest.importorskip("jsonschema") response = client.post( "/api...
payload
assert
variable
tests/test_docs_app_schema.py
test_docs_api_schema_validation_error_returns_400
81
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json from src.json_repair.json_parser import JSONParser from src.json_repair.schema_repair import SchemaRepairer from src.json_repair.utils.json_context import ContextValues def parse_object_direct(raw, schema, *, strict=False, context=None): parser = JSONParser(ra...
[]
assert
collection
tests/test_schema_parser_paths.py
test_parse_object_schema_empty_object_falls_back_to_array
135
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_edge_cases(): assert repair_json("{foo: [}") == '{"foo": []}' assert repair_json('{"": "value"') == '{"": "value"}' assert repair_json('{"key": "v"alue"}') == '{"key": "v\\"alue\\""}' assert repair_json('{"value_1": true, COMMENT...
'{"b": "xxxxx"}'
assert
string_literal
tests/test_parse_object.py
test_parse_object_edge_cases
46
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_applies_to_valid_json_without_skip_json_loads(): pytest.importorskip("jsonschema") schema = { ...
ValueError, match="does not match")
pytest.raises
complex_expr
tests/test_schema_guided_parse.py
test_schema_applies_to_valid_json_without_skip_json_loads
74
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_without_schema_keeps_existing_behavior(client): response = client.post( "/api/repair-json", json={"malfo...
200
assert
numeric_literal
tests/test_docs_app_schema.py
test_docs_api_without_schema_keeps_existing_behavior
21
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_rejects_empty_object_with_extra_characters(): with pytest.raises(
ValueError, match="Parsed object is empty")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_rejects_empty_object_with_extra_characters
35
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_leading_trailing_characters(): assert repair_json('````{ "key": "value" }```') == '{"key": "value"}' assert repair_json("""{ "a": "", "b": [ { "c": 1} ] \n}```""") == '{"a": "", "b": [{"c": 1}]}' assert
'{"a": "b"}'
assert
string_literal
tests/test_parse_string.py
test_leading_trailing_characters
91
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_edge_cases(): assert repair_json("{foo: [}") == '{"foo": []}' assert repair_json('{"": "value"') ==
'{"": "value"}'
assert
string_literal
tests/test_parse_object.py
test_parse_object_edge_cases
25
null
mangiucugna/json_repair
import os import pathlib import pytest from src.json_repair import repair_json path = pathlib.Path(__file__).parent.resolve() CI = os.getenv("CI") is not None correct_json = (path / "valid.json").read_text() incorrect_json = (path / "invalid.json").read_text() @pytest.mark.skipif(CI, reason="Performance tests are...
max_time
assert
variable
tests/test_performance.py
test_true_true_correct
27
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json from src.json_repair.json_parser import JSONParser from src.json_repair.schema_repair import SchemaRepairer from src.json_repair.utils.json_context import ContextValues def parse_object_direct(raw, schema, *, strict=False, context=None): parser = JSONParser(ra...
[True]
assert
collection
tests/test_schema_parser_paths.py
test_parse_array_schema_items_and_additional_items
167
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_negative_indices(tmp_path): file_path = tmp_path / "index.json" file_path.write_text("xyz", encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: wrapper = StringFil...
IndexError)
pytest.raises
variable
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_negative_indices
49
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_rejects_multiple_top_level_values(): with pytest.raises(
ValueError, match="Multiple top-level JSON elements")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_rejects_multiple_top_level_values
7
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_rejects_invalid_schema_repair_mode_value(client): response = client.post( "/api/repair-json", json={"mal...
{"error": "schemaRepairMode must be 'standard' or 'salvage'."}
assert
collection
tests/test_docs_app_schema.py
test_docs_api_rejects_invalid_schema_repair_mode_value
102
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number_edge_cases(): assert ( repair_json(' - { "test_key": ["test_value", "test_value2"] }') == '{"test_key": ["test_value", "test_value2"]}' ) assert repair_json('{"key": 1/3}') == '{"key": "1/3"}' assert repair_json('{"key": ...
"[]"
assert
string_literal
tests/test_parse_number.py
test_parse_number_edge_cases
24
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_array(): assert repair_json("[]", return_objects=True) == [] assert repair_json("[1, 2, 3, 4]", return_objects=True) == [1, 2, 3, 4] assert repair_json("[", return_objects=True) == [] assert repair_json("[[1\n\n]") ==
"[[1]]"
assert
string_literal
tests/test_parse_array.py
test_parse_array
8
null
mangiucugna/json_repair
import pytest from src.json_repair.json_repair import repair_json def test_strict_requires_colon_between_key_and_value(): with pytest.raises(
ValueError, match="Missing ':' after key")
pytest.raises
complex_expr
tests/test_strict_mode.py
test_strict_requires_colon_between_key_and_value
24
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_number(): assert repair_json("1", return_objects=True) == 1 assert repair_json("1.2", return_objects=True) == 1.2 assert repair_json('{"value": 82_461_110}', return_objects=True) ==
{"value": 82461110}
assert
collection
tests/test_parse_number.py
test_parse_number
7
null
mangiucugna/json_repair
import pytest pytest.importorskip("flask") from docs.app import app def client(): app.testing = True with app.test_client() as test_client: yield test_client def test_docs_api_rejects_invalid_schema_type(client): response = client.post( "/api/repair-json", json={"malformedJSON": ...
400
assert
numeric_literal
tests/test_docs_app_schema.py
test_docs_api_rejects_invalid_schema_type
64
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_object_merge_at_the_end(): assert repair_json('{"key": "value"}, "key2": "value2"}') == '{"key": "value", "key2": "value2"}' assert repair_json('{"key": "value"}, "key2": }') ==
'{"key": "value", "key2": ""}'
assert
string_literal
tests/test_parse_object.py
test_parse_object_merge_at_the_end
100
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json def repair_with_schema(raw, schema, **kwargs): return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs) def test_schema_boolean_coercion_accepts_number_tokens(): pytest.importorskip("jsonschema") schema = { "...
{"flag": False}
assert
collection
tests/test_schema_guided_parse.py
test_schema_boolean_coercion_accepts_number_tokens
162
null
mangiucugna/json_repair
import io import json import os import tempfile from pathlib import Path from unittest.mock import patch import pytest from src.json_repair.json_repair import cli def test_cli_schema_applies_to_valid_json(tmp_path, capsys): pytest.importorskip("jsonschema") schema_path = tmp_path / "schema.json" schema =...
'{\n"value": 1\n}\n'
assert
string_literal
tests/test_repair_json_cli.py
test_cli_schema_applies_to_valid_json
105
null
mangiucugna/json_repair
import pytest from src.json_repair import repair_json from src.json_repair.json_parser import JSONParser from src.json_repair.schema_repair import SchemaRepairer from src.json_repair.utils.json_context import ContextValues def parse_object_direct(raw, schema, *, strict=False, context=None): parser = JSONParser(ra...
{"a": 2}
assert
collection
tests/test_schema_parser_paths.py
test_parse_object_schema_drop_property_and_additional_schema
110
null
mangiucugna/json_repair
from src.json_repair.json_repair import repair_json def test_parse_boolean_or_null(): assert repair_json("True", return_objects=True) == "" assert repair_json("False", return_objects=True) == "" assert repair_json("Null", return_objects=True) == "" assert repair_json("true", return_objects=True) as...
None
assert
none_literal
tests/test_parse_string.py
test_parse_boolean_or_null
121
null
mangiucugna/json_repair
import pytest from src.json_repair.utils.string_file_wrapper import StringFileWrapper def test_string_file_wrapper_slice_variations(tmp_path): file_path = tmp_path / "slice.json" file_path.write_text("abcd", encoding="utf-8") with file_path.open("r", encoding="utf-8") as handle: wrapper = StringFi...
"cd"
assert
string_literal
tests/utils/test_string_file_wrapper.py
test_string_file_wrapper_slice_variations
35
null