Harbor format: 871 coding_baseline tasks (part 44)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/tests/trusted-inventory.json +62 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/validation/canaries/original-bug.sh +3 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/validation/openenv.json +27 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/LICENSE.source +7 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/adapter.json +127 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/dependency-setup.sh +17 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/environment/Dockerfile +3 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/instruction.md +37 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/metadata.json +386 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/provenance.json +88 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/provided-gold.diff +15 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/solution/solve.sh +21 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/task.toml +24 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/check_pytest.py +177 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/expected-panels.json +210 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/grade.py +128 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/panel-config.json +23 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/test.sh +6 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted-inventory.json +62 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/pyproject.toml +61 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/pytest.ini +2 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/__init__.py +0 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/conftest.py +27 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_middlewares.py +105 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_operations.py +37 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_queries.py +445 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_storages.py +281 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_tables.py +179 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_tinydb.py +716 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_utils.py +116 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/validation/canaries/original-bug.sh +3 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/validation/openenv.json +27 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/LICENSE.source +7 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/adapter.json +127 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/dependency-setup.sh +17 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/environment/Dockerfile +3 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/instruction.md +41 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/metadata.json +386 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/provenance.json +88 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/provided-gold.diff +35 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/solution/solve.sh +41 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/task.toml +24 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/check_pytest.py +177 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/expected-panels.json +210 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/grade.py +128 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/panel-config.json +23 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/test.sh +6 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted-inventory.json +62 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted/pyproject.toml +61 -0
- tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted/pytest.ini +2 -0
tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/tests/trusted-inventory.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"directory_roots": [
|
| 3 |
+
"tests"
|
| 4 |
+
],
|
| 5 |
+
"files": {
|
| 6 |
+
"pyproject.toml": {
|
| 7 |
+
"bytes": 1846,
|
| 8 |
+
"mode": 420,
|
| 9 |
+
"sha256": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be"
|
| 10 |
+
},
|
| 11 |
+
"pytest.ini": {
|
| 12 |
+
"bytes": 70,
|
| 13 |
+
"mode": 420,
|
| 14 |
+
"sha256": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 15 |
+
},
|
| 16 |
+
"tests/__init__.py": {
|
| 17 |
+
"bytes": 0,
|
| 18 |
+
"mode": 420,
|
| 19 |
+
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
| 20 |
+
},
|
| 21 |
+
"tests/conftest.py": {
|
| 22 |
+
"bytes": 625,
|
| 23 |
+
"mode": 420,
|
| 24 |
+
"sha256": "502596fae1843322ec533028a76474d39e6fb70587a5749d8c9dd734b35e625b"
|
| 25 |
+
},
|
| 26 |
+
"tests/test_middlewares.py": {
|
| 27 |
+
"bytes": 2412,
|
| 28 |
+
"mode": 420,
|
| 29 |
+
"sha256": "85a748d3d10e7be042ed37318153a6b79c7913a5d9536cad406ccccad380577b"
|
| 30 |
+
},
|
| 31 |
+
"tests/test_operations.py": {
|
| 32 |
+
"bytes": 1021,
|
| 33 |
+
"mode": 420,
|
| 34 |
+
"sha256": "6313d342626a12973a5532b0b9344c5a30a959d7bfa4f6ca07d147317aee469e"
|
| 35 |
+
},
|
| 36 |
+
"tests/test_queries.py": {
|
| 37 |
+
"bytes": 12331,
|
| 38 |
+
"mode": 420,
|
| 39 |
+
"sha256": "7978c6220a192f4256018bf37d76e6b4c644a962fed4d6fca7d8594b2cf63a49"
|
| 40 |
+
},
|
| 41 |
+
"tests/test_storages.py": {
|
| 42 |
+
"bytes": 6489,
|
| 43 |
+
"mode": 420,
|
| 44 |
+
"sha256": "d74695d20e1d1742fa558da49bc2df8e84ca34e64e001070cbccce215bd39fa2"
|
| 45 |
+
},
|
| 46 |
+
"tests/test_tables.py": {
|
| 47 |
+
"bytes": 4109,
|
| 48 |
+
"mode": 420,
|
| 49 |
+
"sha256": "f018615899e7c9c813aba0820c639f9402d3c9865a376eedaf9dc3ee89b85ef3"
|
| 50 |
+
},
|
| 51 |
+
"tests/test_tinydb.py": {
|
| 52 |
+
"bytes": 18110,
|
| 53 |
+
"mode": 420,
|
| 54 |
+
"sha256": "d106d5e94536afe8416c1b8b01bc63381abb97f81a6a120743e7e1963b07b1d1"
|
| 55 |
+
},
|
| 56 |
+
"tests/test_utils.py": {
|
| 57 |
+
"bytes": 2257,
|
| 58 |
+
"mode": 420,
|
| 59 |
+
"sha256": "659bd414226988e81d2811259c112676aa6bdfa3b9fb6fed4631030ae6d73f2e"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/validation/canaries/original-bug.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
:
|
tasks/msiemens__tinydb.10644a0e.func_basic__3oacyvpm/validation/openenv.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"canaries": "validation/canaries",
|
| 3 |
+
"profile": "harbor-semantic-v1",
|
| 4 |
+
"requires_credentials": false,
|
| 5 |
+
"resources": {
|
| 6 |
+
"cpu": 2,
|
| 7 |
+
"disk_mb": 16384,
|
| 8 |
+
"episode_timeout_s": 1800,
|
| 9 |
+
"memory_mb": 8192
|
| 10 |
+
},
|
| 11 |
+
"reward": {
|
| 12 |
+
"floor_margin": 0.1,
|
| 13 |
+
"oracle_tolerance": 0,
|
| 14 |
+
"range": [
|
| 15 |
+
0,
|
| 16 |
+
1
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
"reward_key": "reward",
|
| 20 |
+
"types": {
|
| 21 |
+
"tags": [
|
| 22 |
+
"swe",
|
| 23 |
+
"python",
|
| 24 |
+
"mutation-repair"
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/LICENSE.source
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (C) 2013 Markus Siemens <markus@m-siemens.de>
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 4 |
+
|
| 5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/adapter.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.",
|
| 3 |
+
"collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59",
|
| 4 |
+
"dependency_installation_pinned": false,
|
| 5 |
+
"dependency_setup_sha256": "0551e0806afd99add5cb7c6184a7e0b4813c16aa421c4031e64e7e3a27b44236",
|
| 6 |
+
"gold_patch_sha256": "d25f7c52c6eedf21f19339c50d406daf1e92c07d93c363721a4c93349170f779",
|
| 7 |
+
"hostile_code_isolation_established": false,
|
| 8 |
+
"known_wrong_semantic_implementations": 0,
|
| 9 |
+
"native_inventory_sha256": "c855bfeecb949d87ad5ee310b71fdccb479a8284c385533fcb514336e888a8d1",
|
| 10 |
+
"new_files_deletions_and_executable_modes_supported": true,
|
| 11 |
+
"official_profile": {
|
| 12 |
+
"eval_sets": [],
|
| 13 |
+
"profile_class": "Tinydb10644a0e",
|
| 14 |
+
"profile_lines": [
|
| 15 |
+
1020,
|
| 16 |
+
1023
|
| 17 |
+
],
|
| 18 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 19 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 20 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 21 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 22 |
+
"upstream_repo": "msiemens/tinydb"
|
| 23 |
+
},
|
| 24 |
+
"original_bug_canary_nop_equivalent": true,
|
| 25 |
+
"original_bug_runtime_wrongness_established": false,
|
| 26 |
+
"partial_repair_canary": false,
|
| 27 |
+
"partial_repair_sha256": null,
|
| 28 |
+
"partial_repair_wrongness_established": false,
|
| 29 |
+
"provided_original_bug_control": true,
|
| 30 |
+
"repo_url": "https://github.com/swesmith/msiemens__tinydb.10644a0e.git",
|
| 31 |
+
"runtime_image": null,
|
| 32 |
+
"runtime_ready": false,
|
| 33 |
+
"runtime_recipe": {
|
| 34 |
+
"dependency_installation_pinned": false,
|
| 35 |
+
"official_install_cmds": [
|
| 36 |
+
"python -m pip install -e ."
|
| 37 |
+
],
|
| 38 |
+
"official_pytest_argv": [
|
| 39 |
+
"pytest",
|
| 40 |
+
"--disable-warnings",
|
| 41 |
+
"--color=no",
|
| 42 |
+
"--tb=no",
|
| 43 |
+
"--verbose"
|
| 44 |
+
],
|
| 45 |
+
"official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose",
|
| 46 |
+
"panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.",
|
| 47 |
+
"python_version": "3.10",
|
| 48 |
+
"source_bound_test_dependency_cmds": [
|
| 49 |
+
"python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'"
|
| 50 |
+
],
|
| 51 |
+
"test_dependency_source_sha256": {
|
| 52 |
+
"pyproject.toml": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be",
|
| 53 |
+
"pytest.ini": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"runtime_resource_review_required": false,
|
| 57 |
+
"schema": "python-git-patch-jobs-v1",
|
| 58 |
+
"source_base_commit": "f179c61be118377ba74036b8e4c08677601f75d5",
|
| 59 |
+
"source_completion_sha256": "c5edaf5de014610fa5399e23361ca050bf1fc4fa95b5e504080cd6de71273538",
|
| 60 |
+
"source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876",
|
| 61 |
+
"source_pr_url": null,
|
| 62 |
+
"source_record": {
|
| 63 |
+
"anti_training_canary": false,
|
| 64 |
+
"anti_training_reviewed": true,
|
| 65 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 66 |
+
"cloud_launch_ready": false,
|
| 67 |
+
"eligibility": {
|
| 68 |
+
"reasons": [],
|
| 69 |
+
"semantic_nonoverlap_established": false,
|
| 70 |
+
"status": "eligible_for_controls",
|
| 71 |
+
"training_admissible": false,
|
| 72 |
+
"warnings": []
|
| 73 |
+
},
|
| 74 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 75 |
+
"instruction_sha256": "371b2b25f3acff68a02528285202c4df1e13aff19b9d9b053d6b612c1993829d",
|
| 76 |
+
"is_fork": true,
|
| 77 |
+
"learner_path": "tasks/daaea77ab3478975172c588b/learner",
|
| 78 |
+
"license_evidence": {
|
| 79 |
+
"source_code": {
|
| 80 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 81 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 82 |
+
"reviewed": true,
|
| 83 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 84 |
+
"spdx": "MIT",
|
| 85 |
+
"training_allowed": true,
|
| 86 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/f179c61be118377ba74036b8e4c08677601f75d5/LICENSE"
|
| 87 |
+
},
|
| 88 |
+
"task_bundle": {
|
| 89 |
+
"reviewed": true,
|
| 90 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 91 |
+
"spdx": "MIT",
|
| 92 |
+
"training_allowed": true,
|
| 93 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 97 |
+
"patch_sha256": "7e68a1f6993b91db5206d811f40e8fce8959c87149541872514bb1737141ed4c",
|
| 98 |
+
"provenance_path": "tasks/daaea77ab3478975172c588b/source-proof.json",
|
| 99 |
+
"repository_lineage": [
|
| 100 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 101 |
+
"msiemens/tinydb"
|
| 102 |
+
],
|
| 103 |
+
"rfc008_complete": false,
|
| 104 |
+
"runtime_qualified": false,
|
| 105 |
+
"semantic_nonoverlap_established": false,
|
| 106 |
+
"source_commit": "f179c61be118377ba74036b8e4c08677601f75d5",
|
| 107 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 108 |
+
"source_head_commit": "8522dc68e304e58c5b81071c8f0f660b29aab7a5",
|
| 109 |
+
"source_kind": "mutation",
|
| 110 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 111 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 112 |
+
"source_split": "train",
|
| 113 |
+
"target_model_calibrated": false,
|
| 114 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 115 |
+
"task_sha256": "e5855b57cd0fa566fc2bfc005a1225cd2bc811854f032b0737e61aa1a496cc22",
|
| 116 |
+
"training_admissible": false,
|
| 117 |
+
"upstream_identity_reviewed": true,
|
| 118 |
+
"upstream_repo": "msiemens/tinydb",
|
| 119 |
+
"usage": "quarantine_only"
|
| 120 |
+
},
|
| 121 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 122 |
+
"symlink_submodule_changes_supported": false,
|
| 123 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 124 |
+
"transfer": "index-independent-worktree-to-Git-binary-patch",
|
| 125 |
+
"transfer_path": "/testbed/submission.patch",
|
| 126 |
+
"upstream_repo": "msiemens/tinydb"
|
| 127 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/dependency-setup.sh
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
source /opt/miniconda3/bin/activate
|
| 4 |
+
conda activate testbed
|
| 5 |
+
cd /testbed/repo
|
| 6 |
+
python -c 'import sys; assert sys.version_info[:2] == (3, 10)'
|
| 7 |
+
/usr/bin/sha256sum --check <<'OPENENV_NATIVE_TEST_REQUIREMENT'
|
| 8 |
+
4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be pyproject.toml
|
| 9 |
+
OPENENV_NATIVE_TEST_REQUIREMENT
|
| 10 |
+
python -m pip install -e .
|
| 11 |
+
python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'
|
| 12 |
+
|
| 13 |
+
cat > /tmp/openenv-tinydb-yaml.txt <<'OPENENV_PYYAML_PIN'
|
| 14 |
+
PyYAML==6.0.3 --hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b
|
| 15 |
+
OPENENV_PYYAML_PIN
|
| 16 |
+
python -m pip install --no-deps --only-binary=:all: --require-hashes --index-url https://pypi.org/simple -r /tmp/openenv-tinydb-yaml.txt
|
| 17 |
+
python -c 'import yaml; assert yaml.__version__ == "6.0.3"'
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Runtime is selected only by an independently qualified immutable amd64 receipt.
|
| 2 |
+
FROM ubuntu:22.04
|
| 3 |
+
RUN false
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/instruction.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Query.exists() returns False instead of True for existing fields
|
| 2 |
+
|
| 3 |
+
#### Description
|
| 4 |
+
|
| 5 |
+
The `Query.exists()` method is returning `False` for fields that actually exist in documents, when it should return `True`.
|
| 6 |
+
|
| 7 |
+
#### Steps/Code to Reproduce
|
| 8 |
+
|
| 9 |
+
```python
|
| 10 |
+
from tinydb import TinyDB, Query, where
|
| 11 |
+
from tinydb.storages import MemoryStorage
|
| 12 |
+
|
| 13 |
+
# Create a test database with some data
|
| 14 |
+
db = TinyDB(storage=MemoryStorage)
|
| 15 |
+
db.insert({'value': 1})
|
| 16 |
+
db.insert({'value': 2})
|
| 17 |
+
db.insert({'something': 3})
|
| 18 |
+
|
| 19 |
+
# This should find documents with 'value' field, but returns empty list
|
| 20 |
+
query = Query()['value'].exists()
|
| 21 |
+
results = db.search(query)
|
| 22 |
+
print(f"Found {len(results)} documents with 'value' field") # Expected: 2, Actual: 0
|
| 23 |
+
|
| 24 |
+
# Test with where() syntax - same issue
|
| 25 |
+
results2 = db.search(where('value').exists())
|
| 26 |
+
print(f"Found {len(results2)} documents using where syntax") # Expected: 2, Actual: 0
|
| 27 |
+
|
| 28 |
+
# Direct query test
|
| 29 |
+
test_doc = {'value': 5}
|
| 30 |
+
print(f"Query matches document: {query(test_doc)}") # Expected: True, Actual: False
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
The `exists()` method should return `True` when a field exists in a document, but it's currently returning `False` for all cases.
|
| 34 |
+
|
| 35 |
+
## Environment
|
| 36 |
+
|
| 37 |
+
The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest <tests>`. Don't install packages: the tests need nothing else, and the sandbox may have no network access.
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/metadata.json
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"all_runtime_and_training_flags": false,
|
| 3 |
+
"official_profile": {
|
| 4 |
+
"eval_sets": [],
|
| 5 |
+
"profile_class": "Tinydb10644a0e",
|
| 6 |
+
"profile_lines": [
|
| 7 |
+
1020,
|
| 8 |
+
1023
|
| 9 |
+
],
|
| 10 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 11 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 12 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 13 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 14 |
+
"upstream_repo": "msiemens/tinydb"
|
| 15 |
+
},
|
| 16 |
+
"source_healthy_reference_proof": {
|
| 17 |
+
"FAIL_TO_PASS": [
|
| 18 |
+
"tests/test_queries.py::test_path_exists",
|
| 19 |
+
"tests/test_queries.py::test_path_and",
|
| 20 |
+
"tests/test_queries.py::test_has_key",
|
| 21 |
+
"tests/test_queries.py::test_has",
|
| 22 |
+
"tests/test_tinydb.py::test_insert_multiple[memory]",
|
| 23 |
+
"tests/test_tinydb.py::test_insert_multiple[json]",
|
| 24 |
+
"tests/test_tinydb.py::test_search_path[memory]",
|
| 25 |
+
"tests/test_tinydb.py::test_search_path[json]"
|
| 26 |
+
],
|
| 27 |
+
"PASS_TO_PASS": [
|
| 28 |
+
"tests/test_middlewares.py::test_caching",
|
| 29 |
+
"tests/test_middlewares.py::test_caching_read",
|
| 30 |
+
"tests/test_middlewares.py::test_caching_write_many",
|
| 31 |
+
"tests/test_middlewares.py::test_caching_flush",
|
| 32 |
+
"tests/test_middlewares.py::test_caching_flush_manually",
|
| 33 |
+
"tests/test_middlewares.py::test_caching_write",
|
| 34 |
+
"tests/test_middlewares.py::test_nested",
|
| 35 |
+
"tests/test_middlewares.py::test_caching_json_write",
|
| 36 |
+
"tests/test_operations.py::test_delete[memory]",
|
| 37 |
+
"tests/test_operations.py::test_delete[json]",
|
| 38 |
+
"tests/test_operations.py::test_add_int[memory]",
|
| 39 |
+
"tests/test_operations.py::test_add_int[json]",
|
| 40 |
+
"tests/test_operations.py::test_add_str[memory]",
|
| 41 |
+
"tests/test_operations.py::test_add_str[json]",
|
| 42 |
+
"tests/test_operations.py::test_subtract[memory]",
|
| 43 |
+
"tests/test_operations.py::test_subtract[json]",
|
| 44 |
+
"tests/test_operations.py::test_set[memory]",
|
| 45 |
+
"tests/test_operations.py::test_set[json]",
|
| 46 |
+
"tests/test_operations.py::test_increment[memory]",
|
| 47 |
+
"tests/test_operations.py::test_increment[json]",
|
| 48 |
+
"tests/test_operations.py::test_decrement[memory]",
|
| 49 |
+
"tests/test_operations.py::test_decrement[json]",
|
| 50 |
+
"tests/test_queries.py::test_no_path",
|
| 51 |
+
"tests/test_queries.py::test_callable_in_path_with_map",
|
| 52 |
+
"tests/test_queries.py::test_callable_in_path_with_chain",
|
| 53 |
+
"tests/test_queries.py::test_eq",
|
| 54 |
+
"tests/test_queries.py::test_ne",
|
| 55 |
+
"tests/test_queries.py::test_lt",
|
| 56 |
+
"tests/test_queries.py::test_le",
|
| 57 |
+
"tests/test_queries.py::test_gt",
|
| 58 |
+
"tests/test_queries.py::test_ge",
|
| 59 |
+
"tests/test_queries.py::test_or",
|
| 60 |
+
"tests/test_queries.py::test_and",
|
| 61 |
+
"tests/test_queries.py::test_not",
|
| 62 |
+
"tests/test_queries.py::test_regex",
|
| 63 |
+
"tests/test_queries.py::test_custom",
|
| 64 |
+
"tests/test_queries.py::test_custom_with_params",
|
| 65 |
+
"tests/test_queries.py::test_any",
|
| 66 |
+
"tests/test_queries.py::test_all",
|
| 67 |
+
"tests/test_queries.py::test_one_of",
|
| 68 |
+
"tests/test_queries.py::test_hash",
|
| 69 |
+
"tests/test_queries.py::test_orm_usage",
|
| 70 |
+
"tests/test_queries.py::test_repr",
|
| 71 |
+
"tests/test_queries.py::test_subclass",
|
| 72 |
+
"tests/test_queries.py::test_noop",
|
| 73 |
+
"tests/test_queries.py::test_equality",
|
| 74 |
+
"tests/test_queries.py::test_empty_query_error",
|
| 75 |
+
"tests/test_queries.py::test_fragment",
|
| 76 |
+
"tests/test_queries.py::test_fragment_with_path",
|
| 77 |
+
"tests/test_queries.py::test_get_item",
|
| 78 |
+
"tests/test_storages.py::test_json",
|
| 79 |
+
"tests/test_storages.py::test_json_kwargs",
|
| 80 |
+
"tests/test_storages.py::test_json_readwrite",
|
| 81 |
+
"tests/test_storages.py::test_json_read",
|
| 82 |
+
"tests/test_storages.py::test_create_dirs",
|
| 83 |
+
"tests/test_storages.py::test_json_invalid_directory",
|
| 84 |
+
"tests/test_storages.py::test_in_memory",
|
| 85 |
+
"tests/test_storages.py::test_in_memory_close",
|
| 86 |
+
"tests/test_storages.py::test_custom",
|
| 87 |
+
"tests/test_storages.py::test_read_once",
|
| 88 |
+
"tests/test_storages.py::test_custom_with_exception",
|
| 89 |
+
"tests/test_storages.py::test_yaml",
|
| 90 |
+
"tests/test_storages.py::test_encoding",
|
| 91 |
+
"tests/test_tables.py::test_next_id[memory]",
|
| 92 |
+
"tests/test_tables.py::test_next_id[json]",
|
| 93 |
+
"tests/test_tables.py::test_tables_list[memory]",
|
| 94 |
+
"tests/test_tables.py::test_tables_list[json]",
|
| 95 |
+
"tests/test_tables.py::test_one_table[memory]",
|
| 96 |
+
"tests/test_tables.py::test_one_table[json]",
|
| 97 |
+
"tests/test_tables.py::test_multiple_tables[memory]",
|
| 98 |
+
"tests/test_tables.py::test_multiple_tables[json]",
|
| 99 |
+
"tests/test_tables.py::test_caching[memory]",
|
| 100 |
+
"tests/test_tables.py::test_caching[json]",
|
| 101 |
+
"tests/test_tables.py::test_query_cache[memory]",
|
| 102 |
+
"tests/test_tables.py::test_query_cache[json]",
|
| 103 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[memory]",
|
| 104 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[json]",
|
| 105 |
+
"tests/test_tables.py::test_zero_cache_size[memory]",
|
| 106 |
+
"tests/test_tables.py::test_zero_cache_size[json]",
|
| 107 |
+
"tests/test_tables.py::test_query_cache_size[memory]",
|
| 108 |
+
"tests/test_tables.py::test_query_cache_size[json]",
|
| 109 |
+
"tests/test_tables.py::test_lru_cache[memory]",
|
| 110 |
+
"tests/test_tables.py::test_lru_cache[json]",
|
| 111 |
+
"tests/test_tables.py::test_table_is_iterable[memory]",
|
| 112 |
+
"tests/test_tables.py::test_table_is_iterable[json]",
|
| 113 |
+
"tests/test_tables.py::test_table_name[memory]",
|
| 114 |
+
"tests/test_tables.py::test_table_name[json]",
|
| 115 |
+
"tests/test_tables.py::test_table_repr[memory]",
|
| 116 |
+
"tests/test_tables.py::test_table_repr[json]",
|
| 117 |
+
"tests/test_tables.py::test_truncate_table[memory]",
|
| 118 |
+
"tests/test_tables.py::test_truncate_table[json]",
|
| 119 |
+
"tests/test_tables.py::test_persist_table[memory]",
|
| 120 |
+
"tests/test_tables.py::test_persist_table[json]",
|
| 121 |
+
"tests/test_tinydb.py::test_drop_tables[memory]",
|
| 122 |
+
"tests/test_tinydb.py::test_drop_tables[json]",
|
| 123 |
+
"tests/test_tinydb.py::test_all[memory]",
|
| 124 |
+
"tests/test_tinydb.py::test_all[json]",
|
| 125 |
+
"tests/test_tinydb.py::test_insert[memory]",
|
| 126 |
+
"tests/test_tinydb.py::test_insert[json]",
|
| 127 |
+
"tests/test_tinydb.py::test_insert_ids[memory]",
|
| 128 |
+
"tests/test_tinydb.py::test_insert_ids[json]",
|
| 129 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[memory]",
|
| 130 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[json]",
|
| 131 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[memory]",
|
| 132 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[json]",
|
| 133 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[memory]",
|
| 134 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[json]",
|
| 135 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[memory]",
|
| 136 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[json]",
|
| 137 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[memory]",
|
| 138 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[json]",
|
| 139 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[memory]",
|
| 140 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[json]",
|
| 141 |
+
"tests/test_tinydb.py::test_custom_mapping_type_with_json",
|
| 142 |
+
"tests/test_tinydb.py::test_remove[memory]",
|
| 143 |
+
"tests/test_tinydb.py::test_remove[json]",
|
| 144 |
+
"tests/test_tinydb.py::test_remove_all_fails[memory]",
|
| 145 |
+
"tests/test_tinydb.py::test_remove_all_fails[json]",
|
| 146 |
+
"tests/test_tinydb.py::test_remove_multiple[memory]",
|
| 147 |
+
"tests/test_tinydb.py::test_remove_multiple[json]",
|
| 148 |
+
"tests/test_tinydb.py::test_remove_ids[memory]",
|
| 149 |
+
"tests/test_tinydb.py::test_remove_ids[json]",
|
| 150 |
+
"tests/test_tinydb.py::test_remove_returns_ids[memory]",
|
| 151 |
+
"tests/test_tinydb.py::test_remove_returns_ids[json]",
|
| 152 |
+
"tests/test_tinydb.py::test_update[memory]",
|
| 153 |
+
"tests/test_tinydb.py::test_update[json]",
|
| 154 |
+
"tests/test_tinydb.py::test_update_all[memory]",
|
| 155 |
+
"tests/test_tinydb.py::test_update_all[json]",
|
| 156 |
+
"tests/test_tinydb.py::test_update_returns_ids[memory]",
|
| 157 |
+
"tests/test_tinydb.py::test_update_returns_ids[json]",
|
| 158 |
+
"tests/test_tinydb.py::test_update_transform[memory]",
|
| 159 |
+
"tests/test_tinydb.py::test_update_transform[json]",
|
| 160 |
+
"tests/test_tinydb.py::test_update_ids[memory]",
|
| 161 |
+
"tests/test_tinydb.py::test_update_ids[json]",
|
| 162 |
+
"tests/test_tinydb.py::test_update_multiple[memory]",
|
| 163 |
+
"tests/test_tinydb.py::test_update_multiple[json]",
|
| 164 |
+
"tests/test_tinydb.py::test_update_multiple_operation[memory]",
|
| 165 |
+
"tests/test_tinydb.py::test_update_multiple_operation[json]",
|
| 166 |
+
"tests/test_tinydb.py::test_upsert[memory]",
|
| 167 |
+
"tests/test_tinydb.py::test_upsert[json]",
|
| 168 |
+
"tests/test_tinydb.py::test_upsert_by_id[memory]",
|
| 169 |
+
"tests/test_tinydb.py::test_upsert_by_id[json]",
|
| 170 |
+
"tests/test_tinydb.py::test_search[memory]",
|
| 171 |
+
"tests/test_tinydb.py::test_search[json]",
|
| 172 |
+
"tests/test_tinydb.py::test_search_no_results_cache[memory]",
|
| 173 |
+
"tests/test_tinydb.py::test_search_no_results_cache[json]",
|
| 174 |
+
"tests/test_tinydb.py::test_get[memory]",
|
| 175 |
+
"tests/test_tinydb.py::test_get[json]",
|
| 176 |
+
"tests/test_tinydb.py::test_get_ids[memory]",
|
| 177 |
+
"tests/test_tinydb.py::test_get_ids[json]",
|
| 178 |
+
"tests/test_tinydb.py::test_get_multiple_ids[memory]",
|
| 179 |
+
"tests/test_tinydb.py::test_get_multiple_ids[json]",
|
| 180 |
+
"tests/test_tinydb.py::test_get_invalid[memory]",
|
| 181 |
+
"tests/test_tinydb.py::test_get_invalid[json]",
|
| 182 |
+
"tests/test_tinydb.py::test_count[memory]",
|
| 183 |
+
"tests/test_tinydb.py::test_count[json]",
|
| 184 |
+
"tests/test_tinydb.py::test_contains[memory]",
|
| 185 |
+
"tests/test_tinydb.py::test_contains[json]",
|
| 186 |
+
"tests/test_tinydb.py::test_contains_ids[memory]",
|
| 187 |
+
"tests/test_tinydb.py::test_contains_ids[json]",
|
| 188 |
+
"tests/test_tinydb.py::test_contains_invalid[memory]",
|
| 189 |
+
"tests/test_tinydb.py::test_contains_invalid[json]",
|
| 190 |
+
"tests/test_tinydb.py::test_get_idempotent[memory]",
|
| 191 |
+
"tests/test_tinydb.py::test_get_idempotent[json]",
|
| 192 |
+
"tests/test_tinydb.py::test_multiple_dbs",
|
| 193 |
+
"tests/test_tinydb.py::test_storage_closed_once",
|
| 194 |
+
"tests/test_tinydb.py::test_unique_ids",
|
| 195 |
+
"tests/test_tinydb.py::test_lastid_after_open",
|
| 196 |
+
"tests/test_tinydb.py::test_doc_ids_json",
|
| 197 |
+
"tests/test_tinydb.py::test_insert_string",
|
| 198 |
+
"tests/test_tinydb.py::test_insert_invalid_dict",
|
| 199 |
+
"tests/test_tinydb.py::test_gc",
|
| 200 |
+
"tests/test_tinydb.py::test_drop_table",
|
| 201 |
+
"tests/test_tinydb.py::test_empty_write",
|
| 202 |
+
"tests/test_tinydb.py::test_query_cache",
|
| 203 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[memory]",
|
| 204 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[json]",
|
| 205 |
+
"tests/test_tinydb.py::test_repr",
|
| 206 |
+
"tests/test_tinydb.py::test_delete",
|
| 207 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[memory]",
|
| 208 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[json]",
|
| 209 |
+
"tests/test_tinydb.py::test_access_storage",
|
| 210 |
+
"tests/test_tinydb.py::test_empty_db_len",
|
| 211 |
+
"tests/test_tinydb.py::test_insert_on_existing_db",
|
| 212 |
+
"tests/test_tinydb.py::test_storage_access",
|
| 213 |
+
"tests/test_tinydb.py::test_lambda_query",
|
| 214 |
+
"tests/test_utils.py::test_lru_cache",
|
| 215 |
+
"tests/test_utils.py::test_lru_cache_set_multiple",
|
| 216 |
+
"tests/test_utils.py::test_lru_cache_set_update",
|
| 217 |
+
"tests/test_utils.py::test_lru_cache_get",
|
| 218 |
+
"tests/test_utils.py::test_lru_cache_delete",
|
| 219 |
+
"tests/test_utils.py::test_lru_cache_clear",
|
| 220 |
+
"tests/test_utils.py::test_lru_cache_unlimited",
|
| 221 |
+
"tests/test_utils.py::test_lru_cache_unlimited_explicit",
|
| 222 |
+
"tests/test_utils.py::test_lru_cache_iteration_works",
|
| 223 |
+
"tests/test_utils.py::test_freeze"
|
| 224 |
+
],
|
| 225 |
+
"all_git_blobs_modes_verified": true,
|
| 226 |
+
"cloud_launch_ready": false,
|
| 227 |
+
"commits": {
|
| 228 |
+
"bug": "8522dc68e304e58c5b81071c8f0f660b29aab7a5",
|
| 229 |
+
"healthy": "278700580526dd378f18f40b641885ec78df63e1",
|
| 230 |
+
"learner": "f179c61be118377ba74036b8e4c08677601f75d5"
|
| 231 |
+
},
|
| 232 |
+
"existing_squirrel_snapshot_reused": false,
|
| 233 |
+
"full_transfer_allowlist": [
|
| 234 |
+
"/testbed/.coveragerc",
|
| 235 |
+
"/testbed/.github/stale.yml",
|
| 236 |
+
"/testbed/.gitignore",
|
| 237 |
+
"/testbed/.readthedocs.yml",
|
| 238 |
+
"/testbed/CONTRIBUTING.rst",
|
| 239 |
+
"/testbed/LICENSE",
|
| 240 |
+
"/testbed/MANIFEST.in",
|
| 241 |
+
"/testbed/README.rst",
|
| 242 |
+
"/testbed/artwork/logo.png",
|
| 243 |
+
"/testbed/artwork/logo.svg",
|
| 244 |
+
"/testbed/docs/.gitignore",
|
| 245 |
+
"/testbed/docs/Makefile",
|
| 246 |
+
"/testbed/docs/_static/logo.png",
|
| 247 |
+
"/testbed/docs/_templates/links.html",
|
| 248 |
+
"/testbed/docs/_templates/sidebarlogo.html",
|
| 249 |
+
"/testbed/docs/_themes/.gitignore",
|
| 250 |
+
"/testbed/docs/_themes/LICENSE",
|
| 251 |
+
"/testbed/docs/_themes/README",
|
| 252 |
+
"/testbed/docs/_themes/flask/layout.html",
|
| 253 |
+
"/testbed/docs/_themes/flask/page.html",
|
| 254 |
+
"/testbed/docs/_themes/flask/relations.html",
|
| 255 |
+
"/testbed/docs/_themes/flask/static/flasky.css_t",
|
| 256 |
+
"/testbed/docs/_themes/flask/theme.conf",
|
| 257 |
+
"/testbed/docs/_themes/flask_theme_support.py",
|
| 258 |
+
"/testbed/docs/api.rst",
|
| 259 |
+
"/testbed/docs/changelog.rst",
|
| 260 |
+
"/testbed/docs/conf.py",
|
| 261 |
+
"/testbed/docs/contribute.rst",
|
| 262 |
+
"/testbed/docs/extend.rst",
|
| 263 |
+
"/testbed/docs/extensions.rst",
|
| 264 |
+
"/testbed/docs/getting-started.rst",
|
| 265 |
+
"/testbed/docs/index.rst",
|
| 266 |
+
"/testbed/docs/intro.rst",
|
| 267 |
+
"/testbed/docs/make.bat",
|
| 268 |
+
"/testbed/docs/upgrade.rst",
|
| 269 |
+
"/testbed/docs/usage.rst",
|
| 270 |
+
"/testbed/mypy.ini",
|
| 271 |
+
"/testbed/poetry.lock",
|
| 272 |
+
"/testbed/pyproject.toml",
|
| 273 |
+
"/testbed/pytest.ini",
|
| 274 |
+
"/testbed/tests/__init__.py",
|
| 275 |
+
"/testbed/tests/conftest.py",
|
| 276 |
+
"/testbed/tests/test_middlewares.py",
|
| 277 |
+
"/testbed/tests/test_operations.py",
|
| 278 |
+
"/testbed/tests/test_storages.py",
|
| 279 |
+
"/testbed/tests/test_tables.py",
|
| 280 |
+
"/testbed/tests/test_utils.py",
|
| 281 |
+
"/testbed/tinydb/__init__.py",
|
| 282 |
+
"/testbed/tinydb/database.py",
|
| 283 |
+
"/testbed/tinydb/middlewares.py",
|
| 284 |
+
"/testbed/tinydb/mypy_plugin.py",
|
| 285 |
+
"/testbed/tinydb/operations.py",
|
| 286 |
+
"/testbed/tinydb/py.typed",
|
| 287 |
+
"/testbed/tinydb/queries.py",
|
| 288 |
+
"/testbed/tinydb/storages.py",
|
| 289 |
+
"/testbed/tinydb/table.py",
|
| 290 |
+
"/testbed/tinydb/utils.py",
|
| 291 |
+
"/testbed/tinydb/version.py"
|
| 292 |
+
],
|
| 293 |
+
"healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed",
|
| 294 |
+
"mutation_matches_dataset_and_git_blobs": true,
|
| 295 |
+
"official_profile": {
|
| 296 |
+
"eval_sets": [],
|
| 297 |
+
"profile_class": "Tinydb10644a0e",
|
| 298 |
+
"profile_lines": [
|
| 299 |
+
1020,
|
| 300 |
+
1023
|
| 301 |
+
],
|
| 302 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 303 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 304 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 305 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 306 |
+
"upstream_repo": "msiemens/tinydb"
|
| 307 |
+
},
|
| 308 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 309 |
+
"private_test_paths": [
|
| 310 |
+
"tests/test_queries.py",
|
| 311 |
+
"tests/test_tinydb.py"
|
| 312 |
+
],
|
| 313 |
+
"private_tests_unchanged": true,
|
| 314 |
+
"profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference",
|
| 315 |
+
"qwen_calibrated": false,
|
| 316 |
+
"runtime_qualified": false,
|
| 317 |
+
"source_paths": [
|
| 318 |
+
"tinydb/queries.py"
|
| 319 |
+
],
|
| 320 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 321 |
+
"source_stages_bytes": 927478,
|
| 322 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 323 |
+
"transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter",
|
| 324 |
+
"upstream_repo": "msiemens/tinydb"
|
| 325 |
+
},
|
| 326 |
+
"source_record": {
|
| 327 |
+
"anti_training_canary": false,
|
| 328 |
+
"anti_training_reviewed": true,
|
| 329 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 330 |
+
"cloud_launch_ready": false,
|
| 331 |
+
"eligibility": {
|
| 332 |
+
"reasons": [],
|
| 333 |
+
"semantic_nonoverlap_established": false,
|
| 334 |
+
"status": "eligible_for_controls",
|
| 335 |
+
"training_admissible": false,
|
| 336 |
+
"warnings": []
|
| 337 |
+
},
|
| 338 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 339 |
+
"instruction_sha256": "371b2b25f3acff68a02528285202c4df1e13aff19b9d9b053d6b612c1993829d",
|
| 340 |
+
"is_fork": true,
|
| 341 |
+
"learner_path": "tasks/daaea77ab3478975172c588b/learner",
|
| 342 |
+
"license_evidence": {
|
| 343 |
+
"source_code": {
|
| 344 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 345 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 346 |
+
"reviewed": true,
|
| 347 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 348 |
+
"spdx": "MIT",
|
| 349 |
+
"training_allowed": true,
|
| 350 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/f179c61be118377ba74036b8e4c08677601f75d5/LICENSE"
|
| 351 |
+
},
|
| 352 |
+
"task_bundle": {
|
| 353 |
+
"reviewed": true,
|
| 354 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 355 |
+
"spdx": "MIT",
|
| 356 |
+
"training_allowed": true,
|
| 357 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 358 |
+
}
|
| 359 |
+
},
|
| 360 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 361 |
+
"patch_sha256": "7e68a1f6993b91db5206d811f40e8fce8959c87149541872514bb1737141ed4c",
|
| 362 |
+
"provenance_path": "tasks/daaea77ab3478975172c588b/source-proof.json",
|
| 363 |
+
"repository_lineage": [
|
| 364 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 365 |
+
"msiemens/tinydb"
|
| 366 |
+
],
|
| 367 |
+
"rfc008_complete": false,
|
| 368 |
+
"runtime_qualified": false,
|
| 369 |
+
"semantic_nonoverlap_established": false,
|
| 370 |
+
"source_commit": "f179c61be118377ba74036b8e4c08677601f75d5",
|
| 371 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 372 |
+
"source_head_commit": "8522dc68e304e58c5b81071c8f0f660b29aab7a5",
|
| 373 |
+
"source_kind": "mutation",
|
| 374 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 375 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 376 |
+
"source_split": "train",
|
| 377 |
+
"target_model_calibrated": false,
|
| 378 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 379 |
+
"task_sha256": "e5855b57cd0fa566fc2bfc005a1225cd2bc811854f032b0737e61aa1a496cc22",
|
| 380 |
+
"training_admissible": false,
|
| 381 |
+
"upstream_identity_reviewed": true,
|
| 382 |
+
"upstream_repo": "msiemens/tinydb",
|
| 383 |
+
"usage": "quarantine_only"
|
| 384 |
+
},
|
| 385 |
+
"task_kind": "original-source-mutation"
|
| 386 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/provenance.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"generated_reference": false,
|
| 3 |
+
"healthy_reference_delta_sha256": "d25f7c52c6eedf21f19339c50d406daf1e92c07d93c363721a4c93349170f779",
|
| 4 |
+
"native_pytest_ids_preserved": true,
|
| 5 |
+
"original_source_code_license": {
|
| 6 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 7 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 8 |
+
"reviewed": true,
|
| 9 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 10 |
+
"spdx": "MIT",
|
| 11 |
+
"training_allowed": true,
|
| 12 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/f179c61be118377ba74036b8e4c08677601f75d5/LICENSE"
|
| 13 |
+
},
|
| 14 |
+
"provided_reference": true,
|
| 15 |
+
"qwen_calibrated": false,
|
| 16 |
+
"runtime_qualified": false,
|
| 17 |
+
"source_completion_sha256": "c5edaf5de014610fa5399e23361ca050bf1fc4fa95b5e504080cd6de71273538",
|
| 18 |
+
"source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876",
|
| 19 |
+
"source_proof_sha256": "c9193e7a83cc717dcd173ce76fd29c3982813c2061c6df704add77827716830d",
|
| 20 |
+
"source_record": {
|
| 21 |
+
"anti_training_canary": false,
|
| 22 |
+
"anti_training_reviewed": true,
|
| 23 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 24 |
+
"cloud_launch_ready": false,
|
| 25 |
+
"eligibility": {
|
| 26 |
+
"reasons": [],
|
| 27 |
+
"semantic_nonoverlap_established": false,
|
| 28 |
+
"status": "eligible_for_controls",
|
| 29 |
+
"training_admissible": false,
|
| 30 |
+
"warnings": []
|
| 31 |
+
},
|
| 32 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 33 |
+
"instruction_sha256": "371b2b25f3acff68a02528285202c4df1e13aff19b9d9b053d6b612c1993829d",
|
| 34 |
+
"is_fork": true,
|
| 35 |
+
"learner_path": "tasks/daaea77ab3478975172c588b/learner",
|
| 36 |
+
"license_evidence": {
|
| 37 |
+
"source_code": {
|
| 38 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 39 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 40 |
+
"reviewed": true,
|
| 41 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 42 |
+
"spdx": "MIT",
|
| 43 |
+
"training_allowed": true,
|
| 44 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/f179c61be118377ba74036b8e4c08677601f75d5/LICENSE"
|
| 45 |
+
},
|
| 46 |
+
"task_bundle": {
|
| 47 |
+
"reviewed": true,
|
| 48 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 49 |
+
"spdx": "MIT",
|
| 50 |
+
"training_allowed": true,
|
| 51 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 55 |
+
"patch_sha256": "7e68a1f6993b91db5206d811f40e8fce8959c87149541872514bb1737141ed4c",
|
| 56 |
+
"provenance_path": "tasks/daaea77ab3478975172c588b/source-proof.json",
|
| 57 |
+
"repository_lineage": [
|
| 58 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 59 |
+
"msiemens/tinydb"
|
| 60 |
+
],
|
| 61 |
+
"rfc008_complete": false,
|
| 62 |
+
"runtime_qualified": false,
|
| 63 |
+
"semantic_nonoverlap_established": false,
|
| 64 |
+
"source_commit": "f179c61be118377ba74036b8e4c08677601f75d5",
|
| 65 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 66 |
+
"source_head_commit": "8522dc68e304e58c5b81071c8f0f660b29aab7a5",
|
| 67 |
+
"source_kind": "mutation",
|
| 68 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 69 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 70 |
+
"source_split": "train",
|
| 71 |
+
"target_model_calibrated": false,
|
| 72 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__4550j9d7",
|
| 73 |
+
"task_sha256": "e5855b57cd0fa566fc2bfc005a1225cd2bc811854f032b0737e61aa1a496cc22",
|
| 74 |
+
"training_admissible": false,
|
| 75 |
+
"upstream_identity_reviewed": true,
|
| 76 |
+
"upstream_repo": "msiemens/tinydb",
|
| 77 |
+
"usage": "quarantine_only"
|
| 78 |
+
},
|
| 79 |
+
"task_bundle_license": {
|
| 80 |
+
"reviewed": true,
|
| 81 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 82 |
+
"spdx": "MIT",
|
| 83 |
+
"training_allowed": true,
|
| 84 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 85 |
+
},
|
| 86 |
+
"training_admissible": false,
|
| 87 |
+
"trusted_tests_sha256": "ff9a5ef814fab3aeaea8a510213b4330c9b7600d0e4cd9f29754ec6179c0d458"
|
| 88 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/provided-gold.diff
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/tinydb/queries.py b/tinydb/queries.py
|
| 2 |
+
index 4fe011fa4fcefd06247013d393dafec7bce33f92..0ef6a69b545e23bbe3acb710b9200190dd6acd78 100644
|
| 3 |
+
--- a/tinydb/queries.py
|
| 4 |
+
+++ b/tinydb/queries.py
|
| 5 |
+
@@ -325,8 +325,8 @@
|
| 6 |
+
>>> Query().f1.exists()
|
| 7 |
+
"""
|
| 8 |
+
return self._generate_test(
|
| 9 |
+
- lambda _: False,
|
| 10 |
+
- ('missing', self._path)
|
| 11 |
+
+ lambda _: True,
|
| 12 |
+
+ ('exists', self._path)
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
def matches(self, regex: str, flags: int = 0) -> QueryInstance:
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/solution/solve.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
cd /testbed/repo
|
| 4 |
+
cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE'
|
| 5 |
+
diff --git a/tinydb/queries.py b/tinydb/queries.py
|
| 6 |
+
index 4fe011fa4fcefd06247013d393dafec7bce33f92..0ef6a69b545e23bbe3acb710b9200190dd6acd78 100644
|
| 7 |
+
--- a/tinydb/queries.py
|
| 8 |
+
+++ b/tinydb/queries.py
|
| 9 |
+
@@ -325,8 +325,8 @@
|
| 10 |
+
>>> Query().f1.exists()
|
| 11 |
+
"""
|
| 12 |
+
return self._generate_test(
|
| 13 |
+
- lambda _: False,
|
| 14 |
+
- ('missing', self._path)
|
| 15 |
+
+ lambda _: True,
|
| 16 |
+
+ ('exists', self._path)
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
def matches(self, regex: str, flags: int = 0) -> QueryInstance:
|
| 20 |
+
OPENENV_REFERENCE
|
| 21 |
+
/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/task.toml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[agent]
|
| 4 |
+
timeout_sec = 1800.0
|
| 5 |
+
|
| 6 |
+
[verifier]
|
| 7 |
+
timeout_sec = 900.0
|
| 8 |
+
|
| 9 |
+
[environment]
|
| 10 |
+
docker_image = "ghcr.io/younesbelkada/scale800@sha256:1ccfa02601febeda887bd28796526bb5c5d4852f8a0aa02545cc216173fdc358"
|
| 11 |
+
build_timeout_sec = 600.0
|
| 12 |
+
cpus = 2
|
| 13 |
+
memory_mb = 8192
|
| 14 |
+
storage_mb = 16384
|
| 15 |
+
|
| 16 |
+
[metadata]
|
| 17 |
+
author_name = "SWE-smith source adapter"
|
| 18 |
+
category = "bugfix"
|
| 19 |
+
tags = ["swe", "python", "mutation-repair"]
|
| 20 |
+
|
| 21 |
+
[environment.env]
|
| 22 |
+
# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's
|
| 23 |
+
# non-interactive shells never run `conda activate`
|
| 24 |
+
PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/check_pytest.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Preserve confirmed requested assertion failures; keep positive checks strict."""
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import xml.etree.ElementTree as ET
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
GROUPS = ("pass-to-pass", "fail-to-pass")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def split_nodeid(target):
|
| 14 |
+
prefix, bracket, parameter = target.partition("[")
|
| 15 |
+
parts = prefix.split("::")
|
| 16 |
+
if bracket:
|
| 17 |
+
parts[-1] += bracket + parameter
|
| 18 |
+
return parts
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def matches(case, target):
|
| 22 |
+
parts = split_nodeid(target)
|
| 23 |
+
module = parts[0].removesuffix(".py").replace("/", ".")
|
| 24 |
+
classname, name = case.get("classname", ""), case.get("name", "")
|
| 25 |
+
if not (classname == module or classname.startswith(module + ".")):
|
| 26 |
+
return False
|
| 27 |
+
selector = parts[-1] if len(parts) > 1 else ""
|
| 28 |
+
classes = parts[1:-1]
|
| 29 |
+
if classes and classname != module + "." + ".".join(classes):
|
| 30 |
+
return False
|
| 31 |
+
return (
|
| 32 |
+
not selector
|
| 33 |
+
or name == selector
|
| 34 |
+
or ("[" not in selector and name.startswith(selector + "["))
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def capture_panels(root):
|
| 39 |
+
panels, digests = {}, {}
|
| 40 |
+
for group in GROUPS:
|
| 41 |
+
path = Path(root) / (group + ".xml")
|
| 42 |
+
if not path.exists():
|
| 43 |
+
panels[group] = None
|
| 44 |
+
continue
|
| 45 |
+
with path.open("rb") as stream:
|
| 46 |
+
raw = stream.read(4 * 1024**2 + 1)
|
| 47 |
+
if not 0 < len(raw) <= 4 * 1024**2 or re.search(
|
| 48 |
+
rb"<!\s*(?:DOCTYPE|ENTITY)", raw, re.I
|
| 49 |
+
):
|
| 50 |
+
raise ValueError("Unbounded or unsafe pytest XML")
|
| 51 |
+
try:
|
| 52 |
+
tree = ET.fromstring(raw)
|
| 53 |
+
except ET.ParseError:
|
| 54 |
+
raise ValueError("Malformed pytest XML") from None
|
| 55 |
+
cases = list(tree.iter("testcase"))
|
| 56 |
+
if len(cases) > 20000:
|
| 57 |
+
raise ValueError("Too many pytest cases")
|
| 58 |
+
identities = [(case.get("classname"), case.get("name")) for case in cases]
|
| 59 |
+
if len(identities) != len(set(identities)):
|
| 60 |
+
raise ValueError("Duplicate pytest case evidence")
|
| 61 |
+
panels[group] = cases
|
| 62 |
+
digests[group] = hashlib.sha256(raw).hexdigest()
|
| 63 |
+
return panels, digests
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def strict_assess(panels, expected, native_exit):
|
| 67 |
+
"""The original positive-approval conditions, applied to captured cases."""
|
| 68 |
+
all_cases, actual_failure = [], False
|
| 69 |
+
for group in GROUPS:
|
| 70 |
+
cases = panels[group]
|
| 71 |
+
if cases is None:
|
| 72 |
+
if actual_failure:
|
| 73 |
+
continue
|
| 74 |
+
raise ValueError("Missing preceding pytest panel")
|
| 75 |
+
if actual_failure:
|
| 76 |
+
raise ValueError(
|
| 77 |
+
"Pytest evidence continued after the native stop-on-failure"
|
| 78 |
+
)
|
| 79 |
+
targets = expected[group]
|
| 80 |
+
if any(not any(matches(case, target) for target in targets) for case in cases):
|
| 81 |
+
raise ValueError("Unexpected pytest case")
|
| 82 |
+
all_cases.extend(cases)
|
| 83 |
+
failures = [case for case in cases if case.find("failure") is not None]
|
| 84 |
+
if any(
|
| 85 |
+
case.find("error") is not None or case.find("skipped") is not None
|
| 86 |
+
for case in cases
|
| 87 |
+
):
|
| 88 |
+
raise ValueError("Pytest collection/error/skip is not a completed panel")
|
| 89 |
+
actual_failure = actual_failure or bool(failures)
|
| 90 |
+
if not failures and any(
|
| 91 |
+
not any(matches(case, target) for case in cases) for target in targets
|
| 92 |
+
):
|
| 93 |
+
raise ValueError("Declared pytest target never ran")
|
| 94 |
+
if actual_failure:
|
| 95 |
+
if native_exit == 0:
|
| 96 |
+
raise ValueError("Native verifier exit disagrees with pytest failure")
|
| 97 |
+
return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)}
|
| 98 |
+
if native_exit != 0:
|
| 99 |
+
raise ValueError("Setup or native verifier failed without a real test failure")
|
| 100 |
+
if any(panels[group] is None for group in GROUPS):
|
| 101 |
+
raise ValueError("Missing completed pytest panel")
|
| 102 |
+
return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def assess(root, expected, native_exit):
|
| 106 |
+
if type(native_exit) is not int:
|
| 107 |
+
raise ValueError("Native verifier exit must be an integer")
|
| 108 |
+
if not isinstance(expected, dict) or any(
|
| 109 |
+
not isinstance(expected.get(group), list)
|
| 110 |
+
or not expected[group]
|
| 111 |
+
or any(not isinstance(target, str) or not target for target in expected[group])
|
| 112 |
+
for group in GROUPS
|
| 113 |
+
):
|
| 114 |
+
raise ValueError("Complete exact native pytest targets required")
|
| 115 |
+
panels, digests = capture_panels(root)
|
| 116 |
+
counts = {
|
| 117 |
+
"cases": 0,
|
| 118 |
+
"matched_failures": 0,
|
| 119 |
+
"unexpected_cases": 0,
|
| 120 |
+
"unmatched_failures": 0,
|
| 121 |
+
"skipped_cases": 0,
|
| 122 |
+
"error_cases": 0,
|
| 123 |
+
"missing_panels": 0,
|
| 124 |
+
"missing_targets": 0,
|
| 125 |
+
}
|
| 126 |
+
for group in GROUPS:
|
| 127 |
+
cases = panels[group]
|
| 128 |
+
if cases is None:
|
| 129 |
+
counts["missing_panels"] += 1
|
| 130 |
+
counts["missing_targets"] += len(expected[group])
|
| 131 |
+
continue
|
| 132 |
+
counts["cases"] += len(cases)
|
| 133 |
+
for case in cases:
|
| 134 |
+
requested = any(matches(case, target) for target in expected[group])
|
| 135 |
+
failure = case.find("failure") is not None
|
| 136 |
+
counts["matched_failures"] += int(requested and failure)
|
| 137 |
+
counts["unmatched_failures"] += int(not requested and failure)
|
| 138 |
+
counts["unexpected_cases"] += int(not requested)
|
| 139 |
+
counts["skipped_cases"] += int(case.find("skipped") is not None)
|
| 140 |
+
counts["error_cases"] += int(case.find("error") is not None)
|
| 141 |
+
counts["missing_targets"] += sum(
|
| 142 |
+
not any(matches(case, target) for case in cases)
|
| 143 |
+
for target in expected[group]
|
| 144 |
+
)
|
| 145 |
+
if counts["matched_failures"]:
|
| 146 |
+
if native_exit == 0:
|
| 147 |
+
raise ValueError(
|
| 148 |
+
"Native verifier exit disagrees with requested pytest failure"
|
| 149 |
+
)
|
| 150 |
+
return {
|
| 151 |
+
"reward": 0,
|
| 152 |
+
"valid_test_failure": True,
|
| 153 |
+
"cases": counts["cases"],
|
| 154 |
+
"diagnostic_counts": counts,
|
| 155 |
+
"panel_sha256": digests,
|
| 156 |
+
"decision": "confirmed_requested_failure_precedence",
|
| 157 |
+
}
|
| 158 |
+
result = strict_assess(panels, expected, native_exit)
|
| 159 |
+
result.update(diagnostic_counts=counts, panel_sha256=digests)
|
| 160 |
+
return result
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
if __name__ == "__main__":
|
| 164 |
+
parser = argparse.ArgumentParser()
|
| 165 |
+
parser.add_argument("--root", required=True)
|
| 166 |
+
parser.add_argument("--expected", required=True)
|
| 167 |
+
parser.add_argument("--native-exit", type=int, required=True)
|
| 168 |
+
args = parser.parse_args()
|
| 169 |
+
result = assess(
|
| 170 |
+
args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit
|
| 171 |
+
)
|
| 172 |
+
reward = Path(args.root) / "reward.txt"
|
| 173 |
+
if reward.read_text().strip() != str(result["reward"]):
|
| 174 |
+
raise ValueError("Native raw reward disagrees with pytest evidence")
|
| 175 |
+
(Path(args.root) / "pytest-evidence.json").write_text(
|
| 176 |
+
json.dumps(result, sort_keys=True) + "\n"
|
| 177 |
+
)
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/expected-panels.json
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fail-to-pass": [
|
| 3 |
+
"tests/test_queries.py::test_path_exists",
|
| 4 |
+
"tests/test_queries.py::test_path_and",
|
| 5 |
+
"tests/test_queries.py::test_has_key",
|
| 6 |
+
"tests/test_queries.py::test_has",
|
| 7 |
+
"tests/test_tinydb.py::test_insert_multiple[memory]",
|
| 8 |
+
"tests/test_tinydb.py::test_insert_multiple[json]",
|
| 9 |
+
"tests/test_tinydb.py::test_search_path[memory]",
|
| 10 |
+
"tests/test_tinydb.py::test_search_path[json]"
|
| 11 |
+
],
|
| 12 |
+
"pass-to-pass": [
|
| 13 |
+
"tests/test_middlewares.py::test_caching",
|
| 14 |
+
"tests/test_middlewares.py::test_caching_read",
|
| 15 |
+
"tests/test_middlewares.py::test_caching_write_many",
|
| 16 |
+
"tests/test_middlewares.py::test_caching_flush",
|
| 17 |
+
"tests/test_middlewares.py::test_caching_flush_manually",
|
| 18 |
+
"tests/test_middlewares.py::test_caching_write",
|
| 19 |
+
"tests/test_middlewares.py::test_nested",
|
| 20 |
+
"tests/test_middlewares.py::test_caching_json_write",
|
| 21 |
+
"tests/test_operations.py::test_delete[memory]",
|
| 22 |
+
"tests/test_operations.py::test_delete[json]",
|
| 23 |
+
"tests/test_operations.py::test_add_int[memory]",
|
| 24 |
+
"tests/test_operations.py::test_add_int[json]",
|
| 25 |
+
"tests/test_operations.py::test_add_str[memory]",
|
| 26 |
+
"tests/test_operations.py::test_add_str[json]",
|
| 27 |
+
"tests/test_operations.py::test_subtract[memory]",
|
| 28 |
+
"tests/test_operations.py::test_subtract[json]",
|
| 29 |
+
"tests/test_operations.py::test_set[memory]",
|
| 30 |
+
"tests/test_operations.py::test_set[json]",
|
| 31 |
+
"tests/test_operations.py::test_increment[memory]",
|
| 32 |
+
"tests/test_operations.py::test_increment[json]",
|
| 33 |
+
"tests/test_operations.py::test_decrement[memory]",
|
| 34 |
+
"tests/test_operations.py::test_decrement[json]",
|
| 35 |
+
"tests/test_queries.py::test_no_path",
|
| 36 |
+
"tests/test_queries.py::test_callable_in_path_with_map",
|
| 37 |
+
"tests/test_queries.py::test_callable_in_path_with_chain",
|
| 38 |
+
"tests/test_queries.py::test_eq",
|
| 39 |
+
"tests/test_queries.py::test_ne",
|
| 40 |
+
"tests/test_queries.py::test_lt",
|
| 41 |
+
"tests/test_queries.py::test_le",
|
| 42 |
+
"tests/test_queries.py::test_gt",
|
| 43 |
+
"tests/test_queries.py::test_ge",
|
| 44 |
+
"tests/test_queries.py::test_or",
|
| 45 |
+
"tests/test_queries.py::test_and",
|
| 46 |
+
"tests/test_queries.py::test_not",
|
| 47 |
+
"tests/test_queries.py::test_regex",
|
| 48 |
+
"tests/test_queries.py::test_custom",
|
| 49 |
+
"tests/test_queries.py::test_custom_with_params",
|
| 50 |
+
"tests/test_queries.py::test_any",
|
| 51 |
+
"tests/test_queries.py::test_all",
|
| 52 |
+
"tests/test_queries.py::test_one_of",
|
| 53 |
+
"tests/test_queries.py::test_hash",
|
| 54 |
+
"tests/test_queries.py::test_orm_usage",
|
| 55 |
+
"tests/test_queries.py::test_repr",
|
| 56 |
+
"tests/test_queries.py::test_subclass",
|
| 57 |
+
"tests/test_queries.py::test_noop",
|
| 58 |
+
"tests/test_queries.py::test_equality",
|
| 59 |
+
"tests/test_queries.py::test_empty_query_error",
|
| 60 |
+
"tests/test_queries.py::test_fragment",
|
| 61 |
+
"tests/test_queries.py::test_fragment_with_path",
|
| 62 |
+
"tests/test_queries.py::test_get_item",
|
| 63 |
+
"tests/test_storages.py::test_json",
|
| 64 |
+
"tests/test_storages.py::test_json_kwargs",
|
| 65 |
+
"tests/test_storages.py::test_json_readwrite",
|
| 66 |
+
"tests/test_storages.py::test_json_read",
|
| 67 |
+
"tests/test_storages.py::test_create_dirs",
|
| 68 |
+
"tests/test_storages.py::test_json_invalid_directory",
|
| 69 |
+
"tests/test_storages.py::test_in_memory",
|
| 70 |
+
"tests/test_storages.py::test_in_memory_close",
|
| 71 |
+
"tests/test_storages.py::test_custom",
|
| 72 |
+
"tests/test_storages.py::test_read_once",
|
| 73 |
+
"tests/test_storages.py::test_custom_with_exception",
|
| 74 |
+
"tests/test_storages.py::test_yaml",
|
| 75 |
+
"tests/test_storages.py::test_encoding",
|
| 76 |
+
"tests/test_tables.py::test_next_id[memory]",
|
| 77 |
+
"tests/test_tables.py::test_next_id[json]",
|
| 78 |
+
"tests/test_tables.py::test_tables_list[memory]",
|
| 79 |
+
"tests/test_tables.py::test_tables_list[json]",
|
| 80 |
+
"tests/test_tables.py::test_one_table[memory]",
|
| 81 |
+
"tests/test_tables.py::test_one_table[json]",
|
| 82 |
+
"tests/test_tables.py::test_multiple_tables[memory]",
|
| 83 |
+
"tests/test_tables.py::test_multiple_tables[json]",
|
| 84 |
+
"tests/test_tables.py::test_caching[memory]",
|
| 85 |
+
"tests/test_tables.py::test_caching[json]",
|
| 86 |
+
"tests/test_tables.py::test_query_cache[memory]",
|
| 87 |
+
"tests/test_tables.py::test_query_cache[json]",
|
| 88 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[memory]",
|
| 89 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[json]",
|
| 90 |
+
"tests/test_tables.py::test_zero_cache_size[memory]",
|
| 91 |
+
"tests/test_tables.py::test_zero_cache_size[json]",
|
| 92 |
+
"tests/test_tables.py::test_query_cache_size[memory]",
|
| 93 |
+
"tests/test_tables.py::test_query_cache_size[json]",
|
| 94 |
+
"tests/test_tables.py::test_lru_cache[memory]",
|
| 95 |
+
"tests/test_tables.py::test_lru_cache[json]",
|
| 96 |
+
"tests/test_tables.py::test_table_is_iterable[memory]",
|
| 97 |
+
"tests/test_tables.py::test_table_is_iterable[json]",
|
| 98 |
+
"tests/test_tables.py::test_table_name[memory]",
|
| 99 |
+
"tests/test_tables.py::test_table_name[json]",
|
| 100 |
+
"tests/test_tables.py::test_table_repr[memory]",
|
| 101 |
+
"tests/test_tables.py::test_table_repr[json]",
|
| 102 |
+
"tests/test_tables.py::test_truncate_table[memory]",
|
| 103 |
+
"tests/test_tables.py::test_truncate_table[json]",
|
| 104 |
+
"tests/test_tables.py::test_persist_table[memory]",
|
| 105 |
+
"tests/test_tables.py::test_persist_table[json]",
|
| 106 |
+
"tests/test_tinydb.py::test_drop_tables[memory]",
|
| 107 |
+
"tests/test_tinydb.py::test_drop_tables[json]",
|
| 108 |
+
"tests/test_tinydb.py::test_all[memory]",
|
| 109 |
+
"tests/test_tinydb.py::test_all[json]",
|
| 110 |
+
"tests/test_tinydb.py::test_insert[memory]",
|
| 111 |
+
"tests/test_tinydb.py::test_insert[json]",
|
| 112 |
+
"tests/test_tinydb.py::test_insert_ids[memory]",
|
| 113 |
+
"tests/test_tinydb.py::test_insert_ids[json]",
|
| 114 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[memory]",
|
| 115 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[json]",
|
| 116 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[memory]",
|
| 117 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[json]",
|
| 118 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[memory]",
|
| 119 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[json]",
|
| 120 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[memory]",
|
| 121 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[json]",
|
| 122 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[memory]",
|
| 123 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[json]",
|
| 124 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[memory]",
|
| 125 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[json]",
|
| 126 |
+
"tests/test_tinydb.py::test_custom_mapping_type_with_json",
|
| 127 |
+
"tests/test_tinydb.py::test_remove[memory]",
|
| 128 |
+
"tests/test_tinydb.py::test_remove[json]",
|
| 129 |
+
"tests/test_tinydb.py::test_remove_all_fails[memory]",
|
| 130 |
+
"tests/test_tinydb.py::test_remove_all_fails[json]",
|
| 131 |
+
"tests/test_tinydb.py::test_remove_multiple[memory]",
|
| 132 |
+
"tests/test_tinydb.py::test_remove_multiple[json]",
|
| 133 |
+
"tests/test_tinydb.py::test_remove_ids[memory]",
|
| 134 |
+
"tests/test_tinydb.py::test_remove_ids[json]",
|
| 135 |
+
"tests/test_tinydb.py::test_remove_returns_ids[memory]",
|
| 136 |
+
"tests/test_tinydb.py::test_remove_returns_ids[json]",
|
| 137 |
+
"tests/test_tinydb.py::test_update[memory]",
|
| 138 |
+
"tests/test_tinydb.py::test_update[json]",
|
| 139 |
+
"tests/test_tinydb.py::test_update_all[memory]",
|
| 140 |
+
"tests/test_tinydb.py::test_update_all[json]",
|
| 141 |
+
"tests/test_tinydb.py::test_update_returns_ids[memory]",
|
| 142 |
+
"tests/test_tinydb.py::test_update_returns_ids[json]",
|
| 143 |
+
"tests/test_tinydb.py::test_update_transform[memory]",
|
| 144 |
+
"tests/test_tinydb.py::test_update_transform[json]",
|
| 145 |
+
"tests/test_tinydb.py::test_update_ids[memory]",
|
| 146 |
+
"tests/test_tinydb.py::test_update_ids[json]",
|
| 147 |
+
"tests/test_tinydb.py::test_update_multiple[memory]",
|
| 148 |
+
"tests/test_tinydb.py::test_update_multiple[json]",
|
| 149 |
+
"tests/test_tinydb.py::test_update_multiple_operation[memory]",
|
| 150 |
+
"tests/test_tinydb.py::test_update_multiple_operation[json]",
|
| 151 |
+
"tests/test_tinydb.py::test_upsert[memory]",
|
| 152 |
+
"tests/test_tinydb.py::test_upsert[json]",
|
| 153 |
+
"tests/test_tinydb.py::test_upsert_by_id[memory]",
|
| 154 |
+
"tests/test_tinydb.py::test_upsert_by_id[json]",
|
| 155 |
+
"tests/test_tinydb.py::test_search[memory]",
|
| 156 |
+
"tests/test_tinydb.py::test_search[json]",
|
| 157 |
+
"tests/test_tinydb.py::test_search_no_results_cache[memory]",
|
| 158 |
+
"tests/test_tinydb.py::test_search_no_results_cache[json]",
|
| 159 |
+
"tests/test_tinydb.py::test_get[memory]",
|
| 160 |
+
"tests/test_tinydb.py::test_get[json]",
|
| 161 |
+
"tests/test_tinydb.py::test_get_ids[memory]",
|
| 162 |
+
"tests/test_tinydb.py::test_get_ids[json]",
|
| 163 |
+
"tests/test_tinydb.py::test_get_multiple_ids[memory]",
|
| 164 |
+
"tests/test_tinydb.py::test_get_multiple_ids[json]",
|
| 165 |
+
"tests/test_tinydb.py::test_get_invalid[memory]",
|
| 166 |
+
"tests/test_tinydb.py::test_get_invalid[json]",
|
| 167 |
+
"tests/test_tinydb.py::test_count[memory]",
|
| 168 |
+
"tests/test_tinydb.py::test_count[json]",
|
| 169 |
+
"tests/test_tinydb.py::test_contains[memory]",
|
| 170 |
+
"tests/test_tinydb.py::test_contains[json]",
|
| 171 |
+
"tests/test_tinydb.py::test_contains_ids[memory]",
|
| 172 |
+
"tests/test_tinydb.py::test_contains_ids[json]",
|
| 173 |
+
"tests/test_tinydb.py::test_contains_invalid[memory]",
|
| 174 |
+
"tests/test_tinydb.py::test_contains_invalid[json]",
|
| 175 |
+
"tests/test_tinydb.py::test_get_idempotent[memory]",
|
| 176 |
+
"tests/test_tinydb.py::test_get_idempotent[json]",
|
| 177 |
+
"tests/test_tinydb.py::test_multiple_dbs",
|
| 178 |
+
"tests/test_tinydb.py::test_storage_closed_once",
|
| 179 |
+
"tests/test_tinydb.py::test_unique_ids",
|
| 180 |
+
"tests/test_tinydb.py::test_lastid_after_open",
|
| 181 |
+
"tests/test_tinydb.py::test_doc_ids_json",
|
| 182 |
+
"tests/test_tinydb.py::test_insert_string",
|
| 183 |
+
"tests/test_tinydb.py::test_insert_invalid_dict",
|
| 184 |
+
"tests/test_tinydb.py::test_gc",
|
| 185 |
+
"tests/test_tinydb.py::test_drop_table",
|
| 186 |
+
"tests/test_tinydb.py::test_empty_write",
|
| 187 |
+
"tests/test_tinydb.py::test_query_cache",
|
| 188 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[memory]",
|
| 189 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[json]",
|
| 190 |
+
"tests/test_tinydb.py::test_repr",
|
| 191 |
+
"tests/test_tinydb.py::test_delete",
|
| 192 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[memory]",
|
| 193 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[json]",
|
| 194 |
+
"tests/test_tinydb.py::test_access_storage",
|
| 195 |
+
"tests/test_tinydb.py::test_empty_db_len",
|
| 196 |
+
"tests/test_tinydb.py::test_insert_on_existing_db",
|
| 197 |
+
"tests/test_tinydb.py::test_storage_access",
|
| 198 |
+
"tests/test_tinydb.py::test_lambda_query",
|
| 199 |
+
"tests/test_utils.py::test_lru_cache",
|
| 200 |
+
"tests/test_utils.py::test_lru_cache_set_multiple",
|
| 201 |
+
"tests/test_utils.py::test_lru_cache_set_update",
|
| 202 |
+
"tests/test_utils.py::test_lru_cache_get",
|
| 203 |
+
"tests/test_utils.py::test_lru_cache_delete",
|
| 204 |
+
"tests/test_utils.py::test_lru_cache_clear",
|
| 205 |
+
"tests/test_utils.py::test_lru_cache_unlimited",
|
| 206 |
+
"tests/test_utils.py::test_lru_cache_unlimited_explicit",
|
| 207 |
+
"tests/test_utils.py::test_lru_cache_iteration_works",
|
| 208 |
+
"tests/test_utils.py::test_freeze"
|
| 209 |
+
]
|
| 210 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/grade.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Trusted private pytest panel runner. Installed only in a fresh grader Job."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import importlib.util
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import shutil
|
| 8 |
+
import stat
|
| 9 |
+
import subprocess
|
| 10 |
+
from pathlib import Path, PurePosixPath
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def sha(raw):
|
| 14 |
+
return hashlib.sha256(raw).hexdigest()
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def safe(value):
|
| 18 |
+
path = PurePosixPath(value)
|
| 19 |
+
if (
|
| 20 |
+
path.is_absolute()
|
| 21 |
+
or path.as_posix() != value
|
| 22 |
+
or not path.parts
|
| 23 |
+
or any(part in {".", "..", ".git"} for part in path.parts)
|
| 24 |
+
):
|
| 25 |
+
raise ValueError("Unsafe trusted test path")
|
| 26 |
+
return path
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def restore(worktree, private, manifest):
|
| 30 |
+
worktree, private = Path(worktree), Path(private)
|
| 31 |
+
captured = {}
|
| 32 |
+
for name, expected in manifest["files"].items():
|
| 33 |
+
path = private / safe(name)
|
| 34 |
+
info = path.lstat()
|
| 35 |
+
raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b""
|
| 36 |
+
if (
|
| 37 |
+
not stat.S_ISREG(info.st_mode)
|
| 38 |
+
or len(raw) != expected["bytes"]
|
| 39 |
+
or sha(raw) != expected["sha256"]
|
| 40 |
+
or stat.S_IMODE(info.st_mode) != expected["mode"]
|
| 41 |
+
):
|
| 42 |
+
raise ValueError("Trusted private test bytes or modes drifted")
|
| 43 |
+
captured[name] = (raw, expected["mode"])
|
| 44 |
+
# Capture and verify every private byte before changing the submitted tree.
|
| 45 |
+
for name in manifest["directory_roots"]:
|
| 46 |
+
destination = worktree / safe(name)
|
| 47 |
+
if destination.is_symlink():
|
| 48 |
+
raise ValueError("Submitted test directory is a symlink")
|
| 49 |
+
for parent in destination.parents:
|
| 50 |
+
if parent == worktree:
|
| 51 |
+
break
|
| 52 |
+
if parent.is_symlink():
|
| 53 |
+
raise ValueError("Submitted test parent is a symlink")
|
| 54 |
+
if destination.exists():
|
| 55 |
+
if not destination.is_dir():
|
| 56 |
+
raise ValueError("Submitted test directory is not a directory")
|
| 57 |
+
shutil.rmtree(destination)
|
| 58 |
+
for name, (raw, mode) in captured.items():
|
| 59 |
+
destination = worktree / safe(name)
|
| 60 |
+
for parent in destination.parents:
|
| 61 |
+
if parent == worktree:
|
| 62 |
+
break
|
| 63 |
+
if parent.is_symlink():
|
| 64 |
+
raise ValueError("Submitted test parent is a symlink")
|
| 65 |
+
if destination.is_symlink():
|
| 66 |
+
raise ValueError("Submitted trusted file is a symlink")
|
| 67 |
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
| 68 |
+
destination.write_bytes(raw)
|
| 69 |
+
destination.chmod(mode)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def run(worktree, private_root, output, invoke=None):
|
| 73 |
+
private_root, output, worktree = Path(private_root), Path(output), Path(worktree)
|
| 74 |
+
expected = json.loads((private_root / "expected-panels.json").read_bytes())
|
| 75 |
+
config = json.loads((private_root / "panel-config.json").read_bytes())
|
| 76 |
+
manifest = json.loads((private_root / "trusted-inventory.json").read_bytes())
|
| 77 |
+
restore(worktree, private_root / "trusted", manifest)
|
| 78 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 79 |
+
for name in (
|
| 80 |
+
"reward.txt",
|
| 81 |
+
"pass-to-pass.xml",
|
| 82 |
+
"fail-to-pass.xml",
|
| 83 |
+
"pytest-evidence.json",
|
| 84 |
+
):
|
| 85 |
+
(output / name).unlink(missing_ok=True)
|
| 86 |
+
environment = dict(os.environ)
|
| 87 |
+
for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"):
|
| 88 |
+
environment.pop(key, None)
|
| 89 |
+
commands, native_exit = [], 0
|
| 90 |
+
invoke = invoke or subprocess.run
|
| 91 |
+
for group in ("pass-to-pass", "fail-to-pass"):
|
| 92 |
+
if (
|
| 93 |
+
not isinstance(expected[group], list)
|
| 94 |
+
or not expected[group]
|
| 95 |
+
or any(
|
| 96 |
+
not isinstance(target, str) or not target for target in expected[group]
|
| 97 |
+
)
|
| 98 |
+
):
|
| 99 |
+
raise ValueError("Frozen native pytest selectors are incomplete")
|
| 100 |
+
command = [
|
| 101 |
+
*config["official_pytest_argv"],
|
| 102 |
+
"--override-ini=addopts=",
|
| 103 |
+
"--junitxml=" + str(output / (group + ".xml")),
|
| 104 |
+
*expected[group],
|
| 105 |
+
]
|
| 106 |
+
result = invoke(command, cwd=worktree, env=environment, check=False)
|
| 107 |
+
native_exit = result.returncode
|
| 108 |
+
commands.append({"group": group, "argv": command, "exit_code": native_exit})
|
| 109 |
+
if native_exit != 0:
|
| 110 |
+
break
|
| 111 |
+
(output / "pytest-commands.json").write_text(
|
| 112 |
+
json.dumps(commands, sort_keys=True) + "\n"
|
| 113 |
+
)
|
| 114 |
+
spec = importlib.util.spec_from_file_location(
|
| 115 |
+
"trusted_pytest_result", private_root / "check_pytest.py"
|
| 116 |
+
)
|
| 117 |
+
checker = importlib.util.module_from_spec(spec)
|
| 118 |
+
spec.loader.exec_module(checker)
|
| 119 |
+
result = checker.assess(output, expected, native_exit)
|
| 120 |
+
(output / "reward.txt").write_text(str(result["reward"]) + "\n")
|
| 121 |
+
(output / "pytest-evidence.json").write_text(
|
| 122 |
+
json.dumps(result, sort_keys=True) + "\n"
|
| 123 |
+
)
|
| 124 |
+
return result
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
if __name__ == "__main__":
|
| 128 |
+
run("/testbed/repo", "/tests", "/logs/verifier")
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/panel-config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dependency_installation_pinned": false,
|
| 3 |
+
"official_install_cmds": [
|
| 4 |
+
"python -m pip install -e ."
|
| 5 |
+
],
|
| 6 |
+
"official_pytest_argv": [
|
| 7 |
+
"pytest",
|
| 8 |
+
"--disable-warnings",
|
| 9 |
+
"--color=no",
|
| 10 |
+
"--tb=no",
|
| 11 |
+
"--verbose"
|
| 12 |
+
],
|
| 13 |
+
"official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose",
|
| 14 |
+
"panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.",
|
| 15 |
+
"python_version": "3.10",
|
| 16 |
+
"source_bound_test_dependency_cmds": [
|
| 17 |
+
"python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'"
|
| 18 |
+
],
|
| 19 |
+
"test_dependency_source_sha256": {
|
| 20 |
+
"pyproject.toml": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be",
|
| 21 |
+
"pytest.ini": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 22 |
+
}
|
| 23 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/test.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
source /opt/miniconda3/bin/activate
|
| 4 |
+
conda activate testbed
|
| 5 |
+
cd /testbed/repo
|
| 6 |
+
exec python -I /tests/grade.py
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted-inventory.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"directory_roots": [
|
| 3 |
+
"tests"
|
| 4 |
+
],
|
| 5 |
+
"files": {
|
| 6 |
+
"pyproject.toml": {
|
| 7 |
+
"bytes": 1846,
|
| 8 |
+
"mode": 420,
|
| 9 |
+
"sha256": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be"
|
| 10 |
+
},
|
| 11 |
+
"pytest.ini": {
|
| 12 |
+
"bytes": 70,
|
| 13 |
+
"mode": 420,
|
| 14 |
+
"sha256": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 15 |
+
},
|
| 16 |
+
"tests/__init__.py": {
|
| 17 |
+
"bytes": 0,
|
| 18 |
+
"mode": 420,
|
| 19 |
+
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
| 20 |
+
},
|
| 21 |
+
"tests/conftest.py": {
|
| 22 |
+
"bytes": 625,
|
| 23 |
+
"mode": 420,
|
| 24 |
+
"sha256": "502596fae1843322ec533028a76474d39e6fb70587a5749d8c9dd734b35e625b"
|
| 25 |
+
},
|
| 26 |
+
"tests/test_middlewares.py": {
|
| 27 |
+
"bytes": 2412,
|
| 28 |
+
"mode": 420,
|
| 29 |
+
"sha256": "85a748d3d10e7be042ed37318153a6b79c7913a5d9536cad406ccccad380577b"
|
| 30 |
+
},
|
| 31 |
+
"tests/test_operations.py": {
|
| 32 |
+
"bytes": 1021,
|
| 33 |
+
"mode": 420,
|
| 34 |
+
"sha256": "6313d342626a12973a5532b0b9344c5a30a959d7bfa4f6ca07d147317aee469e"
|
| 35 |
+
},
|
| 36 |
+
"tests/test_queries.py": {
|
| 37 |
+
"bytes": 12331,
|
| 38 |
+
"mode": 420,
|
| 39 |
+
"sha256": "7978c6220a192f4256018bf37d76e6b4c644a962fed4d6fca7d8594b2cf63a49"
|
| 40 |
+
},
|
| 41 |
+
"tests/test_storages.py": {
|
| 42 |
+
"bytes": 6489,
|
| 43 |
+
"mode": 420,
|
| 44 |
+
"sha256": "d74695d20e1d1742fa558da49bc2df8e84ca34e64e001070cbccce215bd39fa2"
|
| 45 |
+
},
|
| 46 |
+
"tests/test_tables.py": {
|
| 47 |
+
"bytes": 4109,
|
| 48 |
+
"mode": 420,
|
| 49 |
+
"sha256": "f018615899e7c9c813aba0820c639f9402d3c9865a376eedaf9dc3ee89b85ef3"
|
| 50 |
+
},
|
| 51 |
+
"tests/test_tinydb.py": {
|
| 52 |
+
"bytes": 18110,
|
| 53 |
+
"mode": 420,
|
| 54 |
+
"sha256": "d106d5e94536afe8416c1b8b01bc63381abb97f81a6a120743e7e1963b07b1d1"
|
| 55 |
+
},
|
| 56 |
+
"tests/test_utils.py": {
|
| 57 |
+
"bytes": 2257,
|
| 58 |
+
"mode": 420,
|
| 59 |
+
"sha256": "659bd414226988e81d2811259c112676aa6bdfa3b9fb6fed4631030ae6d73f2e"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/pyproject.toml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.poetry]
|
| 2 |
+
name = "tinydb"
|
| 3 |
+
version = "4.8.2"
|
| 4 |
+
description = "TinyDB is a tiny, document oriented database optimized for your happiness :)"
|
| 5 |
+
authors = ["Markus Siemens <markus@m-siemens.de>"]
|
| 6 |
+
license = "MIT"
|
| 7 |
+
|
| 8 |
+
readme = "README.rst"
|
| 9 |
+
|
| 10 |
+
homepage = "https://github.com/msiemens/tinydb"
|
| 11 |
+
documentation = "https://tinydb.readthedocs.org/"
|
| 12 |
+
|
| 13 |
+
keywords = ["database", "nosql"]
|
| 14 |
+
|
| 15 |
+
classifiers = [
|
| 16 |
+
"Development Status :: 5 - Production/Stable",
|
| 17 |
+
"Intended Audience :: Developers",
|
| 18 |
+
"Intended Audience :: System Administrators",
|
| 19 |
+
"License :: OSI Approved :: MIT License",
|
| 20 |
+
"Topic :: Database",
|
| 21 |
+
"Topic :: Database :: Database Engines/Servers",
|
| 22 |
+
"Topic :: Utilities",
|
| 23 |
+
"Programming Language :: Python :: 3",
|
| 24 |
+
"Programming Language :: Python :: 3.8",
|
| 25 |
+
"Programming Language :: Python :: 3.9",
|
| 26 |
+
"Programming Language :: Python :: 3.10",
|
| 27 |
+
"Programming Language :: Python :: 3.11",
|
| 28 |
+
"Programming Language :: Python :: 3.12",
|
| 29 |
+
"Programming Language :: Python :: 3.13",
|
| 30 |
+
"Programming Language :: Python :: Implementation :: CPython",
|
| 31 |
+
"Programming Language :: Python :: Implementation :: PyPy",
|
| 32 |
+
"Operating System :: OS Independent",
|
| 33 |
+
"Typing :: Typed",
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
packages = [
|
| 37 |
+
{ include = "tinydb" },
|
| 38 |
+
{ include = "tests", format = "sdist" }
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
[tool.poetry.urls]
|
| 42 |
+
"Changelog" = "https://tinydb.readthedocs.io/en/latest/changelog.html"
|
| 43 |
+
"Issues" = "https://github.com/msiemens/tinydb/issues"
|
| 44 |
+
|
| 45 |
+
[tool.poetry.dependencies]
|
| 46 |
+
python = "^3.8"
|
| 47 |
+
|
| 48 |
+
[tool.poetry.dev-dependencies]
|
| 49 |
+
pytest = "^7.2.0"
|
| 50 |
+
pytest-pycodestyle = "^2.3.1"
|
| 51 |
+
pytest-cov = "^4.0.0"
|
| 52 |
+
pycodestyle = "^2.10.0"
|
| 53 |
+
sphinx = "^7.0.0"
|
| 54 |
+
coveralls = "^3.3.1"
|
| 55 |
+
pyyaml = "^6.0"
|
| 56 |
+
pytest-mypy = { version = "^0.10.2", markers = "platform_python_implementation != 'PyPy'" }
|
| 57 |
+
types-PyYAML = "^6.0.0"
|
| 58 |
+
|
| 59 |
+
[build-system]
|
| 60 |
+
requires = ["poetry-core"]
|
| 61 |
+
build-backend = "poetry.core.masonry.api"
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/pytest.ini
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
addopts=--verbose --cov-append --cov-report term --cov tinydb
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/__init__.py
ADDED
|
File without changes
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/conftest.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os.path
|
| 2 |
+
import tempfile
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import pytest # type: ignore
|
| 6 |
+
|
| 7 |
+
from tinydb.middlewares import CachingMiddleware
|
| 8 |
+
from tinydb.storages import MemoryStorage
|
| 9 |
+
from tinydb import TinyDB, JSONStorage
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@pytest.fixture(params=['memory', 'json'])
|
| 13 |
+
def db(request, tmp_path: Path):
|
| 14 |
+
if request.param == 'json':
|
| 15 |
+
db_ = TinyDB(tmp_path / 'test.db', storage=JSONStorage)
|
| 16 |
+
else:
|
| 17 |
+
db_ = TinyDB(storage=MemoryStorage)
|
| 18 |
+
|
| 19 |
+
db_.drop_tables()
|
| 20 |
+
db_.insert_multiple({'int': 1, 'char': c} for c in 'abc')
|
| 21 |
+
|
| 22 |
+
yield db_
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@pytest.fixture
|
| 26 |
+
def storage():
|
| 27 |
+
return CachingMiddleware(MemoryStorage)()
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_middlewares.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from tinydb import TinyDB
|
| 4 |
+
from tinydb.middlewares import CachingMiddleware
|
| 5 |
+
from tinydb.storages import MemoryStorage, JSONStorage
|
| 6 |
+
|
| 7 |
+
doc = {'none': [None, None], 'int': 42, 'float': 3.1415899999999999,
|
| 8 |
+
'list': ['LITE', 'RES_ACID', 'SUS_DEXT'],
|
| 9 |
+
'dict': {'hp': 13, 'sp': 5},
|
| 10 |
+
'bool': [True, False, True, False]}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_caching(storage):
|
| 14 |
+
# Write contents
|
| 15 |
+
storage.write(doc)
|
| 16 |
+
|
| 17 |
+
# Verify contents
|
| 18 |
+
assert doc == storage.read()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def test_caching_read():
|
| 22 |
+
db = TinyDB(storage=CachingMiddleware(MemoryStorage))
|
| 23 |
+
assert db.all() == []
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def test_caching_write_many(storage):
|
| 27 |
+
storage.WRITE_CACHE_SIZE = 3
|
| 28 |
+
|
| 29 |
+
# Storage should be still empty
|
| 30 |
+
assert storage.memory is None
|
| 31 |
+
|
| 32 |
+
# Write contents
|
| 33 |
+
for x in range(2):
|
| 34 |
+
storage.write(doc)
|
| 35 |
+
assert storage.memory is None # Still cached
|
| 36 |
+
|
| 37 |
+
storage.write(doc)
|
| 38 |
+
|
| 39 |
+
# Verify contents: Cache should be emptied and written to storage
|
| 40 |
+
assert storage.memory
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def test_caching_flush(storage):
|
| 44 |
+
# Write contents
|
| 45 |
+
for _ in range(CachingMiddleware.WRITE_CACHE_SIZE - 1):
|
| 46 |
+
storage.write(doc)
|
| 47 |
+
|
| 48 |
+
# Not yet flushed...
|
| 49 |
+
assert storage.memory is None
|
| 50 |
+
|
| 51 |
+
storage.write(doc)
|
| 52 |
+
|
| 53 |
+
# Verify contents: Cache should be emptied and written to storage
|
| 54 |
+
assert storage.memory
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def test_caching_flush_manually(storage):
|
| 58 |
+
# Write contents
|
| 59 |
+
storage.write(doc)
|
| 60 |
+
|
| 61 |
+
storage.flush()
|
| 62 |
+
|
| 63 |
+
# Verify contents: Cache should be emptied and written to storage
|
| 64 |
+
assert storage.memory
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def test_caching_write(storage):
|
| 68 |
+
# Write contents
|
| 69 |
+
storage.write(doc)
|
| 70 |
+
|
| 71 |
+
storage.close()
|
| 72 |
+
|
| 73 |
+
# Verify contents: Cache should be emptied and written to storage
|
| 74 |
+
assert storage.storage.memory
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def test_nested():
|
| 78 |
+
storage = CachingMiddleware(MemoryStorage)
|
| 79 |
+
storage() # Initialization
|
| 80 |
+
|
| 81 |
+
# Write contents
|
| 82 |
+
storage.write(doc)
|
| 83 |
+
|
| 84 |
+
# Verify contents
|
| 85 |
+
assert doc == storage.read()
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def test_caching_json_write(tmpdir):
|
| 89 |
+
path = str(tmpdir.join('test.db'))
|
| 90 |
+
|
| 91 |
+
with TinyDB(path, storage=CachingMiddleware(JSONStorage)) as db:
|
| 92 |
+
db.insert({'key': 'value'})
|
| 93 |
+
|
| 94 |
+
# Verify database filesize
|
| 95 |
+
statinfo = os.stat(path)
|
| 96 |
+
assert statinfo.st_size != 0
|
| 97 |
+
|
| 98 |
+
# Assert JSON file has been closed
|
| 99 |
+
assert db._storage._handle.closed
|
| 100 |
+
|
| 101 |
+
del db
|
| 102 |
+
|
| 103 |
+
# Reopen database
|
| 104 |
+
with TinyDB(path, storage=CachingMiddleware(JSONStorage)) as db:
|
| 105 |
+
assert db.all() == [{'key': 'value'}]
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_operations.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tinydb import where
|
| 2 |
+
from tinydb.operations import delete, increment, decrement, add, subtract, set
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def test_delete(db):
|
| 6 |
+
db.update(delete('int'), where('char') == 'a')
|
| 7 |
+
assert 'int' not in db.get(where('char') == 'a')
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def test_add_int(db):
|
| 11 |
+
db.update(add('int', 5), where('char') == 'a')
|
| 12 |
+
assert db.get(where('char') == 'a')['int'] == 6
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def test_add_str(db):
|
| 16 |
+
db.update(add('char', 'xyz'), where('char') == 'a')
|
| 17 |
+
assert db.get(where('char') == 'axyz')['int'] == 1
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_subtract(db):
|
| 21 |
+
db.update(subtract('int', 5), where('char') == 'a')
|
| 22 |
+
assert db.get(where('char') == 'a')['int'] == -4
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_set(db):
|
| 26 |
+
db.update(set('char', 'xyz'), where('char') == 'a')
|
| 27 |
+
assert db.get(where('char') == 'xyz')['int'] == 1
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_increment(db):
|
| 31 |
+
db.update(increment('int'), where('char') == 'a')
|
| 32 |
+
assert db.get(where('char') == 'a')['int'] == 2
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def test_decrement(db):
|
| 36 |
+
db.update(decrement('int'), where('char') == 'a')
|
| 37 |
+
assert db.get(where('char') == 'a')['int'] == 0
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_queries.py
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
from tinydb.queries import Query, where
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_no_path():
|
| 9 |
+
with pytest.raises(ValueError):
|
| 10 |
+
_ = Query() == 2
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_path_exists():
|
| 14 |
+
query = Query()['value'].exists()
|
| 15 |
+
assert query == where('value').exists()
|
| 16 |
+
assert query({'value': 1})
|
| 17 |
+
assert not query({'something': 1})
|
| 18 |
+
assert hash(query)
|
| 19 |
+
assert hash(query) != hash(where('asd'))
|
| 20 |
+
|
| 21 |
+
query = Query()['value']['val'].exists()
|
| 22 |
+
assert query == where('value')['val'].exists()
|
| 23 |
+
assert query({'value': {'val': 2}})
|
| 24 |
+
assert not query({'value': 1})
|
| 25 |
+
assert not query({'value': {'asd': 1}})
|
| 26 |
+
assert not query({'something': 1})
|
| 27 |
+
assert hash(query)
|
| 28 |
+
assert hash(query) != hash(where('asd'))
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_path_and():
|
| 32 |
+
query = Query()['value'].exists() & (Query()['value'] == 5)
|
| 33 |
+
assert query({'value': 5})
|
| 34 |
+
assert not query({'value': 10})
|
| 35 |
+
assert not query({'something': 1})
|
| 36 |
+
assert hash(query)
|
| 37 |
+
assert hash(query) != hash(where('value'))
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def test_callable_in_path_with_map():
|
| 41 |
+
double = lambda x: x + x
|
| 42 |
+
query = Query().value.map(double) == 10
|
| 43 |
+
assert query({'value': 5})
|
| 44 |
+
assert not query({'value': 10})
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def test_callable_in_path_with_chain():
|
| 48 |
+
rekey = lambda x: {'y': x['a'], 'z': x['b']}
|
| 49 |
+
query = Query().map(rekey).z == 10
|
| 50 |
+
assert query({'a': 5, 'b': 10})
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def test_eq():
|
| 54 |
+
query = Query().value == 1
|
| 55 |
+
assert query({'value': 1})
|
| 56 |
+
assert not query({'value': 2})
|
| 57 |
+
assert hash(query)
|
| 58 |
+
|
| 59 |
+
query = Query().value == [0, 1]
|
| 60 |
+
assert query({'value': [0, 1]})
|
| 61 |
+
assert not query({'value': [0, 1, 2]})
|
| 62 |
+
assert hash(query)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def test_ne():
|
| 66 |
+
query = Query().value != 1
|
| 67 |
+
assert query({'value': 0})
|
| 68 |
+
assert query({'value': 2})
|
| 69 |
+
assert not query({'value': 1})
|
| 70 |
+
assert hash(query)
|
| 71 |
+
|
| 72 |
+
query = Query().value != [0, 1]
|
| 73 |
+
assert query({'value': [0, 1, 2]})
|
| 74 |
+
assert not query({'value': [0, 1]})
|
| 75 |
+
assert hash(query)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def test_lt():
|
| 79 |
+
query = Query().value < 1
|
| 80 |
+
assert query({'value': 0})
|
| 81 |
+
assert not query({'value': 1})
|
| 82 |
+
assert not query({'value': 2})
|
| 83 |
+
assert hash(query)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def test_le():
|
| 87 |
+
query = Query().value <= 1
|
| 88 |
+
assert query({'value': 0})
|
| 89 |
+
assert query({'value': 1})
|
| 90 |
+
assert not query({'value': 2})
|
| 91 |
+
assert hash(query)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def test_gt():
|
| 95 |
+
query = Query().value > 1
|
| 96 |
+
assert query({'value': 2})
|
| 97 |
+
assert not query({'value': 1})
|
| 98 |
+
assert hash(query)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def test_ge():
|
| 102 |
+
query = Query().value >= 1
|
| 103 |
+
assert query({'value': 2})
|
| 104 |
+
assert query({'value': 1})
|
| 105 |
+
assert not query({'value': 0})
|
| 106 |
+
assert hash(query)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def test_or():
|
| 110 |
+
query = (
|
| 111 |
+
(Query().val1 == 1) |
|
| 112 |
+
(Query().val2 == 2)
|
| 113 |
+
)
|
| 114 |
+
assert query({'val1': 1})
|
| 115 |
+
assert query({'val2': 2})
|
| 116 |
+
assert query({'val1': 1, 'val2': 2})
|
| 117 |
+
assert not query({'val1': '', 'val2': ''})
|
| 118 |
+
assert hash(query)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def test_and():
|
| 122 |
+
query = (
|
| 123 |
+
(Query().val1 == 1) &
|
| 124 |
+
(Query().val2 == 2)
|
| 125 |
+
)
|
| 126 |
+
assert query({'val1': 1, 'val2': 2})
|
| 127 |
+
assert not query({'val1': 1})
|
| 128 |
+
assert not query({'val2': 2})
|
| 129 |
+
assert not query({'val1': '', 'val2': ''})
|
| 130 |
+
assert hash(query)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def test_not():
|
| 134 |
+
query = ~ (Query().val1 == 1)
|
| 135 |
+
assert query({'val1': 5, 'val2': 2})
|
| 136 |
+
assert not query({'val1': 1, 'val2': 2})
|
| 137 |
+
assert hash(query)
|
| 138 |
+
|
| 139 |
+
query = (
|
| 140 |
+
(~ (Query().val1 == 1)) &
|
| 141 |
+
(Query().val2 == 2)
|
| 142 |
+
)
|
| 143 |
+
assert query({'val1': '', 'val2': 2})
|
| 144 |
+
assert query({'val2': 2})
|
| 145 |
+
assert not query({'val1': 1, 'val2': 2})
|
| 146 |
+
assert not query({'val1': 1})
|
| 147 |
+
assert not query({'val1': '', 'val2': ''})
|
| 148 |
+
assert hash(query)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def test_has_key():
|
| 152 |
+
query = Query().val3.exists()
|
| 153 |
+
|
| 154 |
+
assert query({'val3': 1})
|
| 155 |
+
assert not query({'val1': 1, 'val2': 2})
|
| 156 |
+
assert hash(query)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def test_regex():
|
| 160 |
+
query = Query().val.matches(r'\d{2}\.')
|
| 161 |
+
|
| 162 |
+
assert query({'val': '42.'})
|
| 163 |
+
assert not query({'val': '44'})
|
| 164 |
+
assert not query({'val': 'ab.'})
|
| 165 |
+
assert not query({'val': 155})
|
| 166 |
+
assert not query({'val': False})
|
| 167 |
+
assert not query({'': None})
|
| 168 |
+
assert hash(query)
|
| 169 |
+
|
| 170 |
+
query = Query().val.search(r'\d+')
|
| 171 |
+
|
| 172 |
+
assert query({'val': 'ab3'})
|
| 173 |
+
assert not query({'val': 'abc'})
|
| 174 |
+
assert not query({'val': ''})
|
| 175 |
+
assert not query({'val': True})
|
| 176 |
+
assert not query({'': None})
|
| 177 |
+
assert hash(query)
|
| 178 |
+
|
| 179 |
+
query = Query().val.search(r'JOHN', flags=re.IGNORECASE)
|
| 180 |
+
assert query({'val': 'john'})
|
| 181 |
+
assert query({'val': 'xJohNx'})
|
| 182 |
+
assert not query({'val': 'JOH'})
|
| 183 |
+
assert not query({'val': 12})
|
| 184 |
+
assert not query({'': None})
|
| 185 |
+
assert hash(query)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def test_custom():
|
| 189 |
+
def test(value):
|
| 190 |
+
return value == 42
|
| 191 |
+
|
| 192 |
+
query = Query().val.test(test)
|
| 193 |
+
|
| 194 |
+
assert query({'val': 42})
|
| 195 |
+
assert not query({'val': 40})
|
| 196 |
+
assert not query({'val': '44'})
|
| 197 |
+
assert not query({'': None})
|
| 198 |
+
assert hash(query)
|
| 199 |
+
|
| 200 |
+
def in_list(value, l):
|
| 201 |
+
return value in l
|
| 202 |
+
|
| 203 |
+
query = Query().val.test(in_list, tuple([25, 35]))
|
| 204 |
+
assert not query({'val': 20})
|
| 205 |
+
assert query({'val': 25})
|
| 206 |
+
assert not query({'val': 30})
|
| 207 |
+
assert query({'val': 35})
|
| 208 |
+
assert not query({'val': 36})
|
| 209 |
+
assert hash(query)
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def test_custom_with_params():
|
| 213 |
+
def test(value, minimum, maximum):
|
| 214 |
+
return minimum <= value <= maximum
|
| 215 |
+
|
| 216 |
+
query = Query().val.test(test, 1, 10)
|
| 217 |
+
|
| 218 |
+
assert query({'val': 5})
|
| 219 |
+
assert not query({'val': 0})
|
| 220 |
+
assert not query({'val': 11})
|
| 221 |
+
assert not query({'': None})
|
| 222 |
+
assert hash(query)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def test_any():
|
| 226 |
+
query = Query().followers.any(Query().name == 'don')
|
| 227 |
+
|
| 228 |
+
assert query({'followers': [{'name': 'don'}, {'name': 'john'}]})
|
| 229 |
+
assert not query({'followers': 1})
|
| 230 |
+
assert not query({})
|
| 231 |
+
assert hash(query)
|
| 232 |
+
|
| 233 |
+
query = Query().followers.any(Query().num.matches('\\d+'))
|
| 234 |
+
assert query({'followers': [{'num': '12'}, {'num': 'abc'}]})
|
| 235 |
+
assert not query({'followers': [{'num': 'abc'}]})
|
| 236 |
+
assert hash(query)
|
| 237 |
+
|
| 238 |
+
query = Query().followers.any(['don', 'jon'])
|
| 239 |
+
assert query({'followers': ['don', 'greg', 'bill']})
|
| 240 |
+
assert not query({'followers': ['greg', 'bill']})
|
| 241 |
+
assert not query({})
|
| 242 |
+
assert hash(query)
|
| 243 |
+
|
| 244 |
+
query = Query().followers.any([{'name': 'don'}, {'name': 'john'}])
|
| 245 |
+
assert query({'followers': [{'name': 'don'}, {'name': 'greg'}]})
|
| 246 |
+
assert not query({'followers': [{'name': 'greg'}]})
|
| 247 |
+
assert hash(query)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def test_all():
|
| 251 |
+
query = Query().followers.all(Query().name == 'don')
|
| 252 |
+
assert query({'followers': [{'name': 'don'}]})
|
| 253 |
+
assert not query({'followers': [{'name': 'don'}, {'name': 'john'}]})
|
| 254 |
+
assert hash(query)
|
| 255 |
+
|
| 256 |
+
query = Query().followers.all(Query().num.matches('\\d+'))
|
| 257 |
+
assert query({'followers': [{'num': '123'}, {'num': '456'}]})
|
| 258 |
+
assert not query({'followers': [{'num': '123'}, {'num': 'abc'}]})
|
| 259 |
+
assert hash(query)
|
| 260 |
+
|
| 261 |
+
query = Query().followers.all(['don', 'john'])
|
| 262 |
+
assert query({'followers': ['don', 'john', 'greg']})
|
| 263 |
+
assert not query({'followers': ['don', 'greg']})
|
| 264 |
+
assert not query({})
|
| 265 |
+
assert hash(query)
|
| 266 |
+
|
| 267 |
+
query = Query().followers.all([{'name': 'jane'}, {'name': 'john'}])
|
| 268 |
+
assert query({'followers': [{'name': 'john'}, {'name': 'jane'}]})
|
| 269 |
+
assert query({'followers': [{'name': 'john'},
|
| 270 |
+
{'name': 'jane'},
|
| 271 |
+
{'name': 'bob'}]})
|
| 272 |
+
assert not query({'followers': [{'name': 'john'}, {'name': 'bob'}]})
|
| 273 |
+
assert hash(query)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def test_has():
|
| 277 |
+
query = Query().key1.key2.exists()
|
| 278 |
+
str(query) # This used to cause a bug...
|
| 279 |
+
|
| 280 |
+
assert query({'key1': {'key2': {'key3': 1}}})
|
| 281 |
+
assert query({'key1': {'key2': 1}})
|
| 282 |
+
assert not query({'key1': 3})
|
| 283 |
+
assert not query({'key1': {'key1': 1}})
|
| 284 |
+
assert not query({'key2': {'key1': 1}})
|
| 285 |
+
assert hash(query)
|
| 286 |
+
|
| 287 |
+
query = Query().key1.key2 == 1
|
| 288 |
+
|
| 289 |
+
assert query({'key1': {'key2': 1}})
|
| 290 |
+
assert not query({'key1': {'key2': 2}})
|
| 291 |
+
assert hash(query)
|
| 292 |
+
|
| 293 |
+
# Nested has: key exists
|
| 294 |
+
query = Query().key1.key2.key3.exists()
|
| 295 |
+
assert query({'key1': {'key2': {'key3': 1}}})
|
| 296 |
+
# Not a dict
|
| 297 |
+
assert not query({'key1': 1})
|
| 298 |
+
assert not query({'key1': {'key2': 1}})
|
| 299 |
+
# Wrong key
|
| 300 |
+
assert not query({'key1': {'key2': {'key0': 1}}})
|
| 301 |
+
assert not query({'key1': {'key0': {'key3': 1}}})
|
| 302 |
+
assert not query({'key0': {'key2': {'key3': 1}}})
|
| 303 |
+
|
| 304 |
+
assert hash(query)
|
| 305 |
+
|
| 306 |
+
# Nested has: check for value
|
| 307 |
+
query = Query().key1.key2.key3 == 1
|
| 308 |
+
assert query({'key1': {'key2': {'key3': 1}}})
|
| 309 |
+
assert not query({'key1': {'key2': {'key3': 0}}})
|
| 310 |
+
assert hash(query)
|
| 311 |
+
|
| 312 |
+
# Test special methods: regex matches
|
| 313 |
+
query = Query().key1.value.matches(r'\d+')
|
| 314 |
+
assert query({'key1': {'value': '123'}})
|
| 315 |
+
assert not query({'key2': {'value': '123'}})
|
| 316 |
+
assert not query({'key2': {'value': 'abc'}})
|
| 317 |
+
assert hash(query)
|
| 318 |
+
|
| 319 |
+
# Test special methods: regex contains
|
| 320 |
+
query = Query().key1.value.search(r'\d+')
|
| 321 |
+
assert query({'key1': {'value': 'a2c'}})
|
| 322 |
+
assert not query({'key2': {'value': 'a2c'}})
|
| 323 |
+
assert not query({'key2': {'value': 'abc'}})
|
| 324 |
+
assert hash(query)
|
| 325 |
+
|
| 326 |
+
# Test special methods: nested has and regex matches
|
| 327 |
+
query = Query().key1.x.y.matches(r'\d+')
|
| 328 |
+
assert query({'key1': {'x': {'y': '123'}}})
|
| 329 |
+
assert not query({'key1': {'x': {'y': 'abc'}}})
|
| 330 |
+
assert hash(query)
|
| 331 |
+
|
| 332 |
+
# Test special method: nested has and regex contains
|
| 333 |
+
query = Query().key1.x.y.search(r'\d+')
|
| 334 |
+
assert query({'key1': {'x': {'y': 'a2c'}}})
|
| 335 |
+
assert not query({'key1': {'x': {'y': 'abc'}}})
|
| 336 |
+
assert hash(query)
|
| 337 |
+
|
| 338 |
+
# Test special methods: custom test
|
| 339 |
+
query = Query().key1.int.test(lambda x: x == 3)
|
| 340 |
+
assert query({'key1': {'int': 3}})
|
| 341 |
+
assert hash(query)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def test_one_of():
|
| 345 |
+
query = Query().key1.one_of(['value 1', 'value 2'])
|
| 346 |
+
assert query({'key1': 'value 1'})
|
| 347 |
+
assert query({'key1': 'value 2'})
|
| 348 |
+
assert not query({'key1': 'value 3'})
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
def test_hash():
|
| 352 |
+
d = {
|
| 353 |
+
Query().key1 == 2: True,
|
| 354 |
+
Query().key1.key2.key3.exists(): True,
|
| 355 |
+
Query().key1.exists() & Query().key2.exists(): True,
|
| 356 |
+
Query().key1.exists() | Query().key2.exists(): True,
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
assert (Query().key1 == 2) in d
|
| 360 |
+
assert (Query().key1.key2.key3.exists()) in d
|
| 361 |
+
assert (Query()['key1.key2'].key3.exists()) not in d
|
| 362 |
+
|
| 363 |
+
# Commutative property of & and |
|
| 364 |
+
assert (Query().key1.exists() & Query().key2.exists()) in d
|
| 365 |
+
assert (Query().key2.exists() & Query().key1.exists()) in d
|
| 366 |
+
assert (Query().key1.exists() | Query().key2.exists()) in d
|
| 367 |
+
assert (Query().key2.exists() | Query().key1.exists()) in d
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
def test_orm_usage():
|
| 371 |
+
data = {'name': 'John', 'age': {'year': 2000}}
|
| 372 |
+
|
| 373 |
+
User = Query()
|
| 374 |
+
query1 = User.name == 'John'
|
| 375 |
+
query2 = User.age.year == 2000
|
| 376 |
+
assert query1(data)
|
| 377 |
+
assert query2(data)
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def test_repr():
|
| 381 |
+
Fruit = Query()
|
| 382 |
+
|
| 383 |
+
assert repr(Fruit) == "Query()"
|
| 384 |
+
assert repr(Fruit.type == 'peach') == "QueryImpl('==', ('type',), 'peach')"
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
def test_subclass():
|
| 388 |
+
# Test that a new query test method in a custom subclass is properly usable
|
| 389 |
+
class MyQueryClass(Query):
|
| 390 |
+
def equal_double(self, rhs):
|
| 391 |
+
return self._generate_test(
|
| 392 |
+
lambda value: value == rhs * 2,
|
| 393 |
+
('equal_double', self._path, rhs)
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
query = MyQueryClass().val.equal_double('42')
|
| 397 |
+
|
| 398 |
+
assert query({'val': '4242'})
|
| 399 |
+
assert not query({'val': '42'})
|
| 400 |
+
assert not query({'': None})
|
| 401 |
+
assert hash(query)
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
def test_noop():
|
| 405 |
+
query = Query().noop()
|
| 406 |
+
|
| 407 |
+
assert query({'foo': True})
|
| 408 |
+
assert query({'foo': None})
|
| 409 |
+
assert query({})
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
def test_equality():
|
| 413 |
+
q = Query()
|
| 414 |
+
assert (q.foo == 2) != 0
|
| 415 |
+
assert (q.foo == 'yes') != ''
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
def test_empty_query_error():
|
| 419 |
+
with pytest.raises(RuntimeError, match='Empty query was evaluated'):
|
| 420 |
+
Query()({})
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
def test_fragment():
|
| 424 |
+
query = Query().fragment({'a': 4, 'b': True})
|
| 425 |
+
|
| 426 |
+
assert query({'a': 4, 'b': True, 'c': 'yes'})
|
| 427 |
+
assert not query({'a': 4, 'c': 'yes'})
|
| 428 |
+
assert not query({'b': True, 'c': 'yes'})
|
| 429 |
+
assert not query({'a': 5, 'b': True, 'c': 'yes'})
|
| 430 |
+
assert not query({'a': 4, 'b': 'no', 'c': 'yes'})
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
def test_fragment_with_path():
|
| 434 |
+
query = Query().doc.fragment({'a': 4, 'b': True})
|
| 435 |
+
|
| 436 |
+
assert query({'doc': {'a': 4, 'b': True, 'c': 'yes'}})
|
| 437 |
+
assert not query({'a': 4, 'b': True, 'c': 'yes'})
|
| 438 |
+
assert not query({'doc': {'a': 4, 'c': 'yes'}})
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
def test_get_item():
|
| 442 |
+
query = Query()['test'] == 1
|
| 443 |
+
|
| 444 |
+
assert query({'test': 1})
|
| 445 |
+
assert not query({'test': 0})
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_storages.py
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
import pytest
|
| 7 |
+
|
| 8 |
+
from tinydb import TinyDB, where
|
| 9 |
+
from tinydb.storages import JSONStorage, MemoryStorage, Storage, touch
|
| 10 |
+
from tinydb.table import Document
|
| 11 |
+
|
| 12 |
+
random.seed()
|
| 13 |
+
|
| 14 |
+
doc = {'none': [None, None], 'int': 42, 'float': 3.1415899999999999,
|
| 15 |
+
'list': ['LITE', 'RES_ACID', 'SUS_DEXT'],
|
| 16 |
+
'dict': {'hp': 13, 'sp': 5},
|
| 17 |
+
'bool': [True, False, True, False]}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_json(tmpdir):
|
| 21 |
+
# Write contents
|
| 22 |
+
path = str(tmpdir.join('test.db'))
|
| 23 |
+
storage = JSONStorage(path)
|
| 24 |
+
storage.write(doc)
|
| 25 |
+
|
| 26 |
+
# Verify contents
|
| 27 |
+
assert doc == storage.read()
|
| 28 |
+
storage.close()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_json_kwargs(tmpdir):
|
| 32 |
+
db_file = tmpdir.join('test.db')
|
| 33 |
+
db = TinyDB(str(db_file), sort_keys=True, indent=4, separators=(',', ': '))
|
| 34 |
+
|
| 35 |
+
# Write contents
|
| 36 |
+
db.insert({'b': 1})
|
| 37 |
+
db.insert({'a': 1})
|
| 38 |
+
|
| 39 |
+
assert db_file.read() == '''{
|
| 40 |
+
"_default": {
|
| 41 |
+
"1": {
|
| 42 |
+
"b": 1
|
| 43 |
+
},
|
| 44 |
+
"2": {
|
| 45 |
+
"a": 1
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
}'''
|
| 49 |
+
db.close()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def test_json_readwrite(tmpdir):
|
| 53 |
+
"""
|
| 54 |
+
Regression test for issue #1
|
| 55 |
+
"""
|
| 56 |
+
path = str(tmpdir.join('test.db'))
|
| 57 |
+
|
| 58 |
+
# Create TinyDB instance
|
| 59 |
+
db = TinyDB(path, storage=JSONStorage)
|
| 60 |
+
|
| 61 |
+
item = {'name': 'A very long entry'}
|
| 62 |
+
item2 = {'name': 'A short one'}
|
| 63 |
+
|
| 64 |
+
def get(s):
|
| 65 |
+
return db.get(where('name') == s)
|
| 66 |
+
|
| 67 |
+
db.insert(item)
|
| 68 |
+
assert get('A very long entry') == item
|
| 69 |
+
|
| 70 |
+
db.remove(where('name') == 'A very long entry')
|
| 71 |
+
assert get('A very long entry') is None
|
| 72 |
+
|
| 73 |
+
db.insert(item2)
|
| 74 |
+
assert get('A short one') == item2
|
| 75 |
+
|
| 76 |
+
db.remove(where('name') == 'A short one')
|
| 77 |
+
assert get('A short one') is None
|
| 78 |
+
|
| 79 |
+
db.close()
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def test_json_read(tmpdir):
|
| 83 |
+
r"""Open a database only for reading"""
|
| 84 |
+
path = str(tmpdir.join('test.db'))
|
| 85 |
+
with pytest.raises(FileNotFoundError):
|
| 86 |
+
db = TinyDB(path, storage=JSONStorage, access_mode='r')
|
| 87 |
+
# Create small database
|
| 88 |
+
db = TinyDB(path, storage=JSONStorage)
|
| 89 |
+
db.insert({'b': 1})
|
| 90 |
+
db.insert({'a': 1})
|
| 91 |
+
db.close()
|
| 92 |
+
# Access in read mode
|
| 93 |
+
db = TinyDB(path, storage=JSONStorage, access_mode='r')
|
| 94 |
+
assert db.get(where('a') == 1) == {'a': 1} # reading is fine
|
| 95 |
+
with pytest.raises(IOError):
|
| 96 |
+
db.insert({'c': 1}) # writing is not
|
| 97 |
+
db.close()
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def test_create_dirs():
|
| 101 |
+
temp_dir = tempfile.gettempdir()
|
| 102 |
+
|
| 103 |
+
while True:
|
| 104 |
+
dname = os.path.join(temp_dir, str(random.getrandbits(20)))
|
| 105 |
+
if not os.path.exists(dname):
|
| 106 |
+
db_dir = dname
|
| 107 |
+
db_file = os.path.join(db_dir, 'db.json')
|
| 108 |
+
break
|
| 109 |
+
|
| 110 |
+
with pytest.raises(IOError):
|
| 111 |
+
JSONStorage(db_file)
|
| 112 |
+
|
| 113 |
+
JSONStorage(db_file, create_dirs=True).close()
|
| 114 |
+
assert os.path.exists(db_file)
|
| 115 |
+
|
| 116 |
+
# Use create_dirs with already existing directory
|
| 117 |
+
JSONStorage(db_file, create_dirs=True).close()
|
| 118 |
+
assert os.path.exists(db_file)
|
| 119 |
+
|
| 120 |
+
os.remove(db_file)
|
| 121 |
+
os.rmdir(db_dir)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def test_json_invalid_directory():
|
| 125 |
+
with pytest.raises(IOError):
|
| 126 |
+
with TinyDB('/this/is/an/invalid/path/db.json', storage=JSONStorage):
|
| 127 |
+
pass
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def test_in_memory():
|
| 131 |
+
# Write contents
|
| 132 |
+
storage = MemoryStorage()
|
| 133 |
+
storage.write(doc)
|
| 134 |
+
|
| 135 |
+
# Verify contents
|
| 136 |
+
assert doc == storage.read()
|
| 137 |
+
|
| 138 |
+
# Test case for #21
|
| 139 |
+
other = MemoryStorage()
|
| 140 |
+
other.write({})
|
| 141 |
+
assert other.read() != storage.read()
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def test_in_memory_close():
|
| 145 |
+
with TinyDB(storage=MemoryStorage) as db:
|
| 146 |
+
db.insert({})
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def test_custom():
|
| 150 |
+
# noinspection PyAbstractClass
|
| 151 |
+
class MyStorage(Storage):
|
| 152 |
+
pass
|
| 153 |
+
|
| 154 |
+
with pytest.raises(TypeError):
|
| 155 |
+
MyStorage()
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def test_read_once():
|
| 159 |
+
count = 0
|
| 160 |
+
|
| 161 |
+
# noinspection PyAbstractClass
|
| 162 |
+
class MyStorage(Storage):
|
| 163 |
+
def __init__(self):
|
| 164 |
+
self.memory = None
|
| 165 |
+
|
| 166 |
+
def read(self):
|
| 167 |
+
nonlocal count
|
| 168 |
+
count += 1
|
| 169 |
+
|
| 170 |
+
return self.memory
|
| 171 |
+
|
| 172 |
+
def write(self, data):
|
| 173 |
+
self.memory = data
|
| 174 |
+
|
| 175 |
+
with TinyDB(storage=MyStorage) as db:
|
| 176 |
+
assert count == 0
|
| 177 |
+
|
| 178 |
+
db.table(db.default_table_name)
|
| 179 |
+
|
| 180 |
+
assert count == 0
|
| 181 |
+
|
| 182 |
+
db.all()
|
| 183 |
+
|
| 184 |
+
assert count == 1
|
| 185 |
+
|
| 186 |
+
db.insert({'foo': 'bar'})
|
| 187 |
+
|
| 188 |
+
assert count == 3 # One for getting the next ID, one for the insert
|
| 189 |
+
|
| 190 |
+
db.all()
|
| 191 |
+
|
| 192 |
+
assert count == 4
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def test_custom_with_exception():
|
| 196 |
+
class MyStorage(Storage):
|
| 197 |
+
def read(self):
|
| 198 |
+
pass
|
| 199 |
+
|
| 200 |
+
def write(self, data):
|
| 201 |
+
pass
|
| 202 |
+
|
| 203 |
+
def __init__(self):
|
| 204 |
+
raise ValueError()
|
| 205 |
+
|
| 206 |
+
def close(self):
|
| 207 |
+
raise RuntimeError()
|
| 208 |
+
|
| 209 |
+
with pytest.raises(ValueError):
|
| 210 |
+
with TinyDB(storage=MyStorage) as db:
|
| 211 |
+
pass
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def test_yaml(tmpdir):
|
| 215 |
+
"""
|
| 216 |
+
:type tmpdir: py._path.local.LocalPath
|
| 217 |
+
"""
|
| 218 |
+
|
| 219 |
+
try:
|
| 220 |
+
import yaml
|
| 221 |
+
except ImportError:
|
| 222 |
+
return pytest.skip('PyYAML not installed')
|
| 223 |
+
|
| 224 |
+
def represent_doc(dumper, data):
|
| 225 |
+
# Represent `Document` objects as their dict's string representation
|
| 226 |
+
# which PyYAML understands
|
| 227 |
+
return dumper.represent_data(dict(data))
|
| 228 |
+
|
| 229 |
+
yaml.add_representer(Document, represent_doc)
|
| 230 |
+
|
| 231 |
+
class YAMLStorage(Storage):
|
| 232 |
+
def __init__(self, filename):
|
| 233 |
+
self.filename = filename
|
| 234 |
+
touch(filename, False)
|
| 235 |
+
|
| 236 |
+
def read(self):
|
| 237 |
+
with open(self.filename) as handle:
|
| 238 |
+
data = yaml.safe_load(handle.read())
|
| 239 |
+
return data
|
| 240 |
+
|
| 241 |
+
def write(self, data):
|
| 242 |
+
with open(self.filename, 'w') as handle:
|
| 243 |
+
yaml.dump(data, handle)
|
| 244 |
+
|
| 245 |
+
def close(self):
|
| 246 |
+
pass
|
| 247 |
+
|
| 248 |
+
# Write contents
|
| 249 |
+
path = str(tmpdir.join('test.db'))
|
| 250 |
+
db = TinyDB(path, storage=YAMLStorage)
|
| 251 |
+
db.insert(doc)
|
| 252 |
+
assert db.all() == [doc]
|
| 253 |
+
|
| 254 |
+
db.update({'name': 'foo'})
|
| 255 |
+
|
| 256 |
+
assert '!' not in tmpdir.join('test.db').read()
|
| 257 |
+
|
| 258 |
+
assert db.contains(where('name') == 'foo')
|
| 259 |
+
assert len(db) == 1
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def test_encoding(tmpdir):
|
| 263 |
+
japanese_doc = {"Test": u"こんにちは世界"}
|
| 264 |
+
|
| 265 |
+
path = str(tmpdir.join('test.db'))
|
| 266 |
+
# cp936 is used for japanese encodings
|
| 267 |
+
jap_storage = JSONStorage(path, encoding="cp936")
|
| 268 |
+
jap_storage.write(japanese_doc)
|
| 269 |
+
|
| 270 |
+
try:
|
| 271 |
+
exception = json.decoder.JSONDecodeError
|
| 272 |
+
except AttributeError:
|
| 273 |
+
exception = ValueError
|
| 274 |
+
|
| 275 |
+
with pytest.raises(exception):
|
| 276 |
+
# cp037 is used for english encodings
|
| 277 |
+
eng_storage = JSONStorage(path, encoding="cp037")
|
| 278 |
+
eng_storage.read()
|
| 279 |
+
|
| 280 |
+
jap_storage = JSONStorage(path, encoding="cp936")
|
| 281 |
+
assert japanese_doc == jap_storage.read()
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_tables.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
from tinydb import where
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_next_id(db):
|
| 9 |
+
db.truncate()
|
| 10 |
+
|
| 11 |
+
assert db._get_next_id() == 1
|
| 12 |
+
assert db._get_next_id() == 2
|
| 13 |
+
assert db._get_next_id() == 3
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def test_tables_list(db):
|
| 17 |
+
db.table('table1').insert({'a': 1})
|
| 18 |
+
db.table('table2').insert({'a': 1})
|
| 19 |
+
|
| 20 |
+
assert db.tables() == {'_default', 'table1', 'table2'}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def test_one_table(db):
|
| 24 |
+
table1 = db.table('table1')
|
| 25 |
+
|
| 26 |
+
table1.insert_multiple({'int': 1, 'char': c} for c in 'abc')
|
| 27 |
+
|
| 28 |
+
assert table1.get(where('int') == 1)['char'] == 'a'
|
| 29 |
+
assert table1.get(where('char') == 'b')['char'] == 'b'
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_multiple_tables(db):
|
| 33 |
+
table1 = db.table('table1')
|
| 34 |
+
table2 = db.table('table2')
|
| 35 |
+
table3 = db.table('table3')
|
| 36 |
+
|
| 37 |
+
table1.insert({'int': 1, 'char': 'a'})
|
| 38 |
+
table2.insert({'int': 1, 'char': 'b'})
|
| 39 |
+
table3.insert({'int': 1, 'char': 'c'})
|
| 40 |
+
|
| 41 |
+
assert table1.count(where('char') == 'a') == 1
|
| 42 |
+
assert table2.count(where('char') == 'b') == 1
|
| 43 |
+
assert table3.count(where('char') == 'c') == 1
|
| 44 |
+
|
| 45 |
+
db.drop_tables()
|
| 46 |
+
|
| 47 |
+
assert len(table1) == 0
|
| 48 |
+
assert len(table2) == 0
|
| 49 |
+
assert len(table3) == 0
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def test_caching(db):
|
| 53 |
+
table1 = db.table('table1')
|
| 54 |
+
table2 = db.table('table1')
|
| 55 |
+
|
| 56 |
+
assert table1 is table2
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def test_query_cache(db):
|
| 60 |
+
query1 = where('int') == 1
|
| 61 |
+
|
| 62 |
+
assert db.count(query1) == 3
|
| 63 |
+
assert query1 in db._query_cache
|
| 64 |
+
|
| 65 |
+
assert db.count(query1) == 3
|
| 66 |
+
assert query1 in db._query_cache
|
| 67 |
+
|
| 68 |
+
query2 = where('int') == 0
|
| 69 |
+
|
| 70 |
+
assert db.count(query2) == 0
|
| 71 |
+
assert query2 in db._query_cache
|
| 72 |
+
|
| 73 |
+
assert db.count(query2) == 0
|
| 74 |
+
assert query2 in db._query_cache
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def test_query_cache_with_mutable_callable(db):
|
| 78 |
+
table = db.table('table')
|
| 79 |
+
table.insert({'val': 5})
|
| 80 |
+
|
| 81 |
+
mutable = 5
|
| 82 |
+
increase = lambda x: x + mutable
|
| 83 |
+
|
| 84 |
+
assert where('val').is_cacheable()
|
| 85 |
+
assert not where('val').map(increase).is_cacheable()
|
| 86 |
+
assert not (where('val').map(increase) == 10).is_cacheable()
|
| 87 |
+
|
| 88 |
+
search = where('val').map(increase) == 10
|
| 89 |
+
assert table.count(search) == 1
|
| 90 |
+
|
| 91 |
+
# now `increase` would yield 15, not 10
|
| 92 |
+
mutable = 10
|
| 93 |
+
|
| 94 |
+
assert table.count(search) == 0
|
| 95 |
+
assert len(table._query_cache) == 0
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def test_zero_cache_size(db):
|
| 99 |
+
table = db.table('table3', cache_size=0)
|
| 100 |
+
query = where('int') == 1
|
| 101 |
+
|
| 102 |
+
table.insert({'int': 1})
|
| 103 |
+
table.insert({'int': 1})
|
| 104 |
+
|
| 105 |
+
assert table.count(query) == 2
|
| 106 |
+
assert table.count(where('int') == 2) == 0
|
| 107 |
+
assert len(table._query_cache) == 0
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def test_query_cache_size(db):
|
| 111 |
+
table = db.table('table3', cache_size=1)
|
| 112 |
+
query = where('int') == 1
|
| 113 |
+
|
| 114 |
+
table.insert({'int': 1})
|
| 115 |
+
table.insert({'int': 1})
|
| 116 |
+
|
| 117 |
+
assert table.count(query) == 2
|
| 118 |
+
assert table.count(where('int') == 2) == 0
|
| 119 |
+
assert len(table._query_cache) == 1
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def test_lru_cache(db):
|
| 123 |
+
# Test integration into TinyDB
|
| 124 |
+
table = db.table('table3', cache_size=2)
|
| 125 |
+
query = where('int') == 1
|
| 126 |
+
|
| 127 |
+
table.search(query)
|
| 128 |
+
table.search(where('int') == 2)
|
| 129 |
+
table.search(where('int') == 3)
|
| 130 |
+
assert query not in table._query_cache
|
| 131 |
+
|
| 132 |
+
table.remove(where('int') == 1)
|
| 133 |
+
assert not table._query_cache.lru
|
| 134 |
+
|
| 135 |
+
table.search(query)
|
| 136 |
+
|
| 137 |
+
assert len(table._query_cache) == 1
|
| 138 |
+
table.clear_cache()
|
| 139 |
+
assert len(table._query_cache) == 0
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def test_table_is_iterable(db):
|
| 143 |
+
table = db.table('table1')
|
| 144 |
+
|
| 145 |
+
table.insert_multiple({'int': i} for i in range(3))
|
| 146 |
+
|
| 147 |
+
assert [r for r in table] == table.all()
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def test_table_name(db):
|
| 151 |
+
name = 'table3'
|
| 152 |
+
table = db.table(name)
|
| 153 |
+
assert name == table.name
|
| 154 |
+
|
| 155 |
+
with pytest.raises(AttributeError):
|
| 156 |
+
table.name = 'foo'
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def test_table_repr(db):
|
| 160 |
+
name = 'table4'
|
| 161 |
+
table = db.table(name)
|
| 162 |
+
|
| 163 |
+
assert re.match(
|
| 164 |
+
r"<Table name=\'table4\', total=0, "
|
| 165 |
+
r"storage=<tinydb\.storages\.(MemoryStorage|JSONStorage) object at [a-zA-Z0-9]+>>",
|
| 166 |
+
repr(table))
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def test_truncate_table(db):
|
| 170 |
+
db.truncate()
|
| 171 |
+
assert db._get_next_id() == 1
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def test_persist_table(db):
|
| 175 |
+
db.table("persisted", persist_empty=True)
|
| 176 |
+
assert "persisted" in db.tables()
|
| 177 |
+
|
| 178 |
+
db.table("nonpersisted", persist_empty=False)
|
| 179 |
+
assert "nonpersisted" not in db.tables()
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_tinydb.py
ADDED
|
@@ -0,0 +1,716 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from collections.abc import Mapping
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from tinydb import TinyDB, where, Query
|
| 7 |
+
from tinydb.middlewares import Middleware, CachingMiddleware
|
| 8 |
+
from tinydb.storages import MemoryStorage, JSONStorage
|
| 9 |
+
from tinydb.table import Document
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def test_drop_tables(db: TinyDB):
|
| 13 |
+
db.drop_tables()
|
| 14 |
+
|
| 15 |
+
db.insert({})
|
| 16 |
+
db.drop_tables()
|
| 17 |
+
|
| 18 |
+
assert len(db) == 0
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def test_all(db: TinyDB):
|
| 22 |
+
db.drop_tables()
|
| 23 |
+
|
| 24 |
+
for i in range(10):
|
| 25 |
+
db.insert({})
|
| 26 |
+
|
| 27 |
+
assert len(db.all()) == 10
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_insert(db: TinyDB):
|
| 31 |
+
db.drop_tables()
|
| 32 |
+
db.insert({'int': 1, 'char': 'a'})
|
| 33 |
+
|
| 34 |
+
assert db.count(where('int') == 1) == 1
|
| 35 |
+
|
| 36 |
+
db.drop_tables()
|
| 37 |
+
|
| 38 |
+
db.insert({'int': 1, 'char': 'a'})
|
| 39 |
+
db.insert({'int': 1, 'char': 'b'})
|
| 40 |
+
db.insert({'int': 1, 'char': 'c'})
|
| 41 |
+
|
| 42 |
+
assert db.count(where('int') == 1) == 3
|
| 43 |
+
assert db.count(where('char') == 'a') == 1
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def test_insert_ids(db: TinyDB):
|
| 47 |
+
db.drop_tables()
|
| 48 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 1
|
| 49 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 2
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def test_insert_with_doc_id(db: TinyDB):
|
| 53 |
+
db.drop_tables()
|
| 54 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 1
|
| 55 |
+
assert db.insert(Document({'int': 1, 'char': 'a'}, 12)) == 12
|
| 56 |
+
assert db.insert(Document({'int': 1, 'char': 'a'}, 77)) == 77
|
| 57 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 78
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def test_insert_with_duplicate_doc_id(db: TinyDB):
|
| 61 |
+
db.drop_tables()
|
| 62 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 1
|
| 63 |
+
|
| 64 |
+
with pytest.raises(ValueError):
|
| 65 |
+
db.insert(Document({'int': 1, 'char': 'a'}, 1))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def test_insert_multiple(db: TinyDB):
|
| 69 |
+
db.drop_tables()
|
| 70 |
+
assert not db.contains(where('int') == 1)
|
| 71 |
+
|
| 72 |
+
# Insert multiple from list
|
| 73 |
+
db.insert_multiple([{'int': 1, 'char': 'a'},
|
| 74 |
+
{'int': 1, 'char': 'b'},
|
| 75 |
+
{'int': 1, 'char': 'c'}])
|
| 76 |
+
|
| 77 |
+
assert db.count(where('int') == 1) == 3
|
| 78 |
+
assert db.count(where('char') == 'a') == 1
|
| 79 |
+
|
| 80 |
+
# Insert multiple from generator function
|
| 81 |
+
def generator():
|
| 82 |
+
for j in range(10):
|
| 83 |
+
yield {'int': j}
|
| 84 |
+
|
| 85 |
+
db.drop_tables()
|
| 86 |
+
|
| 87 |
+
db.insert_multiple(generator())
|
| 88 |
+
|
| 89 |
+
for i in range(10):
|
| 90 |
+
assert db.count(where('int') == i) == 1
|
| 91 |
+
assert db.count(where('int').exists()) == 10
|
| 92 |
+
|
| 93 |
+
# Insert multiple from inline generator
|
| 94 |
+
db.drop_tables()
|
| 95 |
+
|
| 96 |
+
db.insert_multiple({'int': i} for i in range(10))
|
| 97 |
+
|
| 98 |
+
for i in range(10):
|
| 99 |
+
assert db.count(where('int') == i) == 1
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def test_insert_multiple_with_ids(db: TinyDB):
|
| 103 |
+
db.drop_tables()
|
| 104 |
+
|
| 105 |
+
# Insert multiple from list
|
| 106 |
+
assert db.insert_multiple([{'int': 1, 'char': 'a'},
|
| 107 |
+
{'int': 1, 'char': 'b'},
|
| 108 |
+
{'int': 1, 'char': 'c'}]) == [1, 2, 3]
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def test_insert_multiple_with_doc_ids(db: TinyDB):
|
| 112 |
+
db.drop_tables()
|
| 113 |
+
|
| 114 |
+
assert db.insert_multiple([
|
| 115 |
+
Document({'int': 1, 'char': 'a'}, 12),
|
| 116 |
+
Document({'int': 1, 'char': 'b'}, 77)
|
| 117 |
+
]) == [12, 77]
|
| 118 |
+
assert db.get(doc_id=12) == {'int': 1, 'char': 'a'}
|
| 119 |
+
assert db.get(doc_id=77) == {'int': 1, 'char': 'b'}
|
| 120 |
+
|
| 121 |
+
with pytest.raises(ValueError):
|
| 122 |
+
db.insert_multiple([Document({'int': 1, 'char': 'a'}, 12)])
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def test_insert_invalid_type_raises_error(db: TinyDB):
|
| 126 |
+
with pytest.raises(ValueError, match='Document is not a Mapping'):
|
| 127 |
+
# object() as an example of a non-mapping-type
|
| 128 |
+
db.insert(object()) # type: ignore
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def test_insert_valid_mapping_type(db: TinyDB):
|
| 132 |
+
class CustomDocument(Mapping):
|
| 133 |
+
def __init__(self, data):
|
| 134 |
+
self.data = data
|
| 135 |
+
|
| 136 |
+
def __getitem__(self, key):
|
| 137 |
+
return self.data[key]
|
| 138 |
+
|
| 139 |
+
def __iter__(self):
|
| 140 |
+
return iter(self.data)
|
| 141 |
+
|
| 142 |
+
def __len__(self):
|
| 143 |
+
return len(self.data)
|
| 144 |
+
|
| 145 |
+
db.drop_tables()
|
| 146 |
+
db.insert(CustomDocument({'int': 1, 'char': 'a'}))
|
| 147 |
+
assert db.count(where('int') == 1) == 1
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def test_custom_mapping_type_with_json(tmpdir):
|
| 151 |
+
class CustomDocument(Mapping):
|
| 152 |
+
def __init__(self, data):
|
| 153 |
+
self.data = data
|
| 154 |
+
|
| 155 |
+
def __getitem__(self, key):
|
| 156 |
+
return self.data[key]
|
| 157 |
+
|
| 158 |
+
def __iter__(self):
|
| 159 |
+
return iter(self.data)
|
| 160 |
+
|
| 161 |
+
def __len__(self):
|
| 162 |
+
return len(self.data)
|
| 163 |
+
|
| 164 |
+
# Insert
|
| 165 |
+
db = TinyDB(str(tmpdir.join('test.db')))
|
| 166 |
+
db.drop_tables()
|
| 167 |
+
db.insert(CustomDocument({'int': 1, 'char': 'a'}))
|
| 168 |
+
assert db.count(where('int') == 1) == 1
|
| 169 |
+
|
| 170 |
+
# Insert multiple
|
| 171 |
+
db.insert_multiple([
|
| 172 |
+
CustomDocument({'int': 2, 'char': 'a'}),
|
| 173 |
+
CustomDocument({'int': 3, 'char': 'a'})
|
| 174 |
+
])
|
| 175 |
+
assert db.count(where('int') == 1) == 1
|
| 176 |
+
assert db.count(where('int') == 2) == 1
|
| 177 |
+
assert db.count(where('int') == 3) == 1
|
| 178 |
+
|
| 179 |
+
# Write back
|
| 180 |
+
doc_id = db.get(where('int') == 3).doc_id
|
| 181 |
+
db.update(CustomDocument({'int': 4, 'char': 'a'}), doc_ids=[doc_id])
|
| 182 |
+
assert db.count(where('int') == 3) == 0
|
| 183 |
+
assert db.count(where('int') == 4) == 1
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def test_remove(db: TinyDB):
|
| 187 |
+
db.remove(where('char') == 'b')
|
| 188 |
+
|
| 189 |
+
assert len(db) == 2
|
| 190 |
+
assert db.count(where('int') == 1) == 2
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def test_remove_all_fails(db: TinyDB):
|
| 194 |
+
with pytest.raises(RuntimeError):
|
| 195 |
+
db.remove()
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def test_remove_multiple(db: TinyDB):
|
| 199 |
+
db.remove(where('int') == 1)
|
| 200 |
+
|
| 201 |
+
assert len(db) == 0
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def test_remove_ids(db: TinyDB):
|
| 205 |
+
db.remove(doc_ids=[1, 2])
|
| 206 |
+
|
| 207 |
+
assert len(db) == 1
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def test_remove_returns_ids(db: TinyDB):
|
| 211 |
+
assert db.remove(where('char') == 'b') == [2]
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def test_update(db: TinyDB):
|
| 215 |
+
assert len(db) == 3
|
| 216 |
+
|
| 217 |
+
db.update({'int': 2}, where('char') == 'a')
|
| 218 |
+
|
| 219 |
+
assert db.count(where('int') == 2) == 1
|
| 220 |
+
assert db.count(where('int') == 1) == 2
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def test_update_all(db: TinyDB):
|
| 224 |
+
assert db.count(where('int') == 1) == 3
|
| 225 |
+
|
| 226 |
+
db.update({'newField': True})
|
| 227 |
+
|
| 228 |
+
assert db.count(where('newField') == True) == 3 # noqa
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def test_update_returns_ids(db: TinyDB):
|
| 232 |
+
db.drop_tables()
|
| 233 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 1
|
| 234 |
+
assert db.insert({'int': 1, 'char': 'a'}) == 2
|
| 235 |
+
|
| 236 |
+
assert db.update({'char': 'b'}, where('int') == 1) == [1, 2]
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def test_update_transform(db: TinyDB):
|
| 240 |
+
def increment(field):
|
| 241 |
+
def transform(el):
|
| 242 |
+
el[field] += 1
|
| 243 |
+
|
| 244 |
+
return transform
|
| 245 |
+
|
| 246 |
+
def delete(field):
|
| 247 |
+
def transform(el):
|
| 248 |
+
del el[field]
|
| 249 |
+
|
| 250 |
+
return transform
|
| 251 |
+
|
| 252 |
+
assert db.count(where('int') == 1) == 3
|
| 253 |
+
|
| 254 |
+
db.update(increment('int'), where('char') == 'a')
|
| 255 |
+
db.update(delete('char'), where('char') == 'a')
|
| 256 |
+
|
| 257 |
+
assert db.count(where('int') == 2) == 1
|
| 258 |
+
assert db.count(where('char') == 'a') == 0
|
| 259 |
+
assert db.count(where('int') == 1) == 2
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def test_update_ids(db: TinyDB):
|
| 263 |
+
db.update({'int': 2}, doc_ids=[1, 2])
|
| 264 |
+
|
| 265 |
+
assert db.count(where('int') == 2) == 2
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def test_update_multiple(db: TinyDB):
|
| 269 |
+
assert len(db) == 3
|
| 270 |
+
|
| 271 |
+
db.update_multiple([
|
| 272 |
+
({'int': 2}, where('char') == 'a'),
|
| 273 |
+
({'int': 4}, where('char') == 'b'),
|
| 274 |
+
])
|
| 275 |
+
|
| 276 |
+
assert db.count(where('int') == 1) == 1
|
| 277 |
+
assert db.count(where('int') == 2) == 1
|
| 278 |
+
assert db.count(where('int') == 4) == 1
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def test_update_multiple_operation(db: TinyDB):
|
| 282 |
+
def increment(field):
|
| 283 |
+
def transform(el):
|
| 284 |
+
el[field] += 1
|
| 285 |
+
|
| 286 |
+
return transform
|
| 287 |
+
|
| 288 |
+
assert db.count(where('int') == 1) == 3
|
| 289 |
+
|
| 290 |
+
db.update_multiple([
|
| 291 |
+
(increment('int'), where('char') == 'a'),
|
| 292 |
+
(increment('int'), where('char') == 'b')
|
| 293 |
+
])
|
| 294 |
+
|
| 295 |
+
assert db.count(where('int') == 2) == 2
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def test_upsert(db: TinyDB):
|
| 299 |
+
assert len(db) == 3
|
| 300 |
+
|
| 301 |
+
# Document existing
|
| 302 |
+
db.upsert({'int': 5}, where('char') == 'a')
|
| 303 |
+
assert db.count(where('int') == 5) == 1
|
| 304 |
+
|
| 305 |
+
# Document missing
|
| 306 |
+
assert db.upsert({'int': 9, 'char': 'x'}, where('char') == 'x') == [4]
|
| 307 |
+
assert db.count(where('int') == 9) == 1
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def test_upsert_by_id(db: TinyDB):
|
| 311 |
+
assert len(db) == 3
|
| 312 |
+
|
| 313 |
+
# Single document existing
|
| 314 |
+
extant_doc = Document({'char': 'v'}, doc_id=1)
|
| 315 |
+
assert db.upsert(extant_doc) == [1]
|
| 316 |
+
doc = db.get(where('char') == 'v')
|
| 317 |
+
assert isinstance(doc, Document)
|
| 318 |
+
assert doc is not None
|
| 319 |
+
assert doc.doc_id == 1
|
| 320 |
+
assert len(db) == 3
|
| 321 |
+
|
| 322 |
+
# Single document missing
|
| 323 |
+
missing_doc = Document({'int': 5, 'char': 'w'}, doc_id=5)
|
| 324 |
+
assert db.upsert(missing_doc) == [5]
|
| 325 |
+
doc = db.get(where('char') == 'w')
|
| 326 |
+
assert isinstance(doc, Document)
|
| 327 |
+
assert doc is not None
|
| 328 |
+
assert doc.doc_id == 5
|
| 329 |
+
assert len(db) == 4
|
| 330 |
+
|
| 331 |
+
# Missing doc_id and condition
|
| 332 |
+
with pytest.raises(ValueError, match=r"(?=.*\bdoc_id\b)(?=.*\bquery\b)"):
|
| 333 |
+
db.upsert({'no_Document': 'no_query'})
|
| 334 |
+
|
| 335 |
+
# Make sure we didn't break anything
|
| 336 |
+
assert db.insert({'check': '_next_id'}) == 6
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def test_search(db: TinyDB):
|
| 340 |
+
assert not db._query_cache
|
| 341 |
+
assert len(db.search(where('int') == 1)) == 3
|
| 342 |
+
|
| 343 |
+
assert len(db._query_cache) == 1
|
| 344 |
+
assert len(db.search(where('int') == 1)) == 3 # Query result from cache
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def test_search_path(db: TinyDB):
|
| 348 |
+
assert not db._query_cache
|
| 349 |
+
assert len(db.search(where('int').exists())) == 3
|
| 350 |
+
assert len(db._query_cache) == 1
|
| 351 |
+
|
| 352 |
+
assert len(db.search(where('asd').exists())) == 0
|
| 353 |
+
assert len(db.search(where('int').exists())) == 3 # Query result from cache
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def test_search_no_results_cache(db: TinyDB):
|
| 357 |
+
assert len(db.search(where('missing').exists())) == 0
|
| 358 |
+
assert len(db.search(where('missing').exists())) == 0
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
def test_get(db: TinyDB):
|
| 362 |
+
item = db.get(where('char') == 'b')
|
| 363 |
+
assert isinstance(item, Document)
|
| 364 |
+
assert item is not None
|
| 365 |
+
assert item['char'] == 'b'
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
def test_get_ids(db: TinyDB):
|
| 369 |
+
el = db.all()[0]
|
| 370 |
+
assert db.get(doc_id=el.doc_id) == el
|
| 371 |
+
assert db.get(doc_id=float('NaN')) is None # type: ignore
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def test_get_multiple_ids(db: TinyDB):
|
| 375 |
+
el = db.all()
|
| 376 |
+
assert db.get(doc_ids=[x.doc_id for x in el]) == el
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
def test_get_invalid(db: TinyDB):
|
| 380 |
+
with pytest.raises(RuntimeError):
|
| 381 |
+
db.get()
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def test_count(db: TinyDB):
|
| 385 |
+
assert db.count(where('int') == 1) == 3
|
| 386 |
+
assert db.count(where('char') == 'd') == 0
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def test_contains(db: TinyDB):
|
| 390 |
+
assert db.contains(where('int') == 1)
|
| 391 |
+
assert not db.contains(where('int') == 0)
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
def test_contains_ids(db: TinyDB):
|
| 395 |
+
assert db.contains(doc_id=1)
|
| 396 |
+
assert db.contains(doc_id=2)
|
| 397 |
+
assert not db.contains(doc_id=88)
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
def test_contains_invalid(db: TinyDB):
|
| 401 |
+
with pytest.raises(RuntimeError):
|
| 402 |
+
db.contains()
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
def test_get_idempotent(db: TinyDB):
|
| 406 |
+
u = db.get(where('int') == 1)
|
| 407 |
+
z = db.get(where('int') == 1)
|
| 408 |
+
assert u == z
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
def test_multiple_dbs():
|
| 412 |
+
"""
|
| 413 |
+
Regression test for issue #3
|
| 414 |
+
"""
|
| 415 |
+
db1 = TinyDB(storage=MemoryStorage)
|
| 416 |
+
db2 = TinyDB(storage=MemoryStorage)
|
| 417 |
+
|
| 418 |
+
db1.insert({'int': 1, 'char': 'a'})
|
| 419 |
+
db1.insert({'int': 1, 'char': 'b'})
|
| 420 |
+
db1.insert({'int': 1, 'value': 5.0})
|
| 421 |
+
|
| 422 |
+
db2.insert({'color': 'blue', 'animal': 'turtle'})
|
| 423 |
+
|
| 424 |
+
assert len(db1) == 3
|
| 425 |
+
assert len(db2) == 1
|
| 426 |
+
|
| 427 |
+
|
| 428 |
+
def test_storage_closed_once():
|
| 429 |
+
class Storage:
|
| 430 |
+
def __init__(self):
|
| 431 |
+
self.closed = False
|
| 432 |
+
|
| 433 |
+
def read(self):
|
| 434 |
+
return {}
|
| 435 |
+
|
| 436 |
+
def write(self, data):
|
| 437 |
+
pass
|
| 438 |
+
|
| 439 |
+
def close(self):
|
| 440 |
+
assert not self.closed
|
| 441 |
+
self.closed = True
|
| 442 |
+
|
| 443 |
+
with TinyDB(storage=Storage) as db:
|
| 444 |
+
db.close()
|
| 445 |
+
|
| 446 |
+
del db
|
| 447 |
+
# If db.close() is called during cleanup, the assertion will fail and throw
|
| 448 |
+
# and exception
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
def test_unique_ids(tmpdir):
|
| 452 |
+
"""
|
| 453 |
+
:type tmpdir: py._path.local.LocalPath
|
| 454 |
+
"""
|
| 455 |
+
path = str(tmpdir.join('db.json'))
|
| 456 |
+
|
| 457 |
+
# Verify ids are unique when reopening the DB and inserting
|
| 458 |
+
with TinyDB(path) as _db:
|
| 459 |
+
_db.insert({'x': 1})
|
| 460 |
+
|
| 461 |
+
with TinyDB(path) as _db:
|
| 462 |
+
_db.insert({'x': 1})
|
| 463 |
+
|
| 464 |
+
with TinyDB(path) as _db:
|
| 465 |
+
data = _db.all()
|
| 466 |
+
|
| 467 |
+
assert data[0].doc_id != data[1].doc_id
|
| 468 |
+
|
| 469 |
+
# Verify ids stay unique when inserting/removing
|
| 470 |
+
with TinyDB(path) as _db:
|
| 471 |
+
_db.drop_tables()
|
| 472 |
+
_db.insert_multiple({'x': i} for i in range(5))
|
| 473 |
+
_db.remove(where('x') == 2)
|
| 474 |
+
|
| 475 |
+
assert len(_db) == 4
|
| 476 |
+
|
| 477 |
+
ids = [e.doc_id for e in _db.all()]
|
| 478 |
+
assert len(ids) == len(set(ids))
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
def test_lastid_after_open(tmpdir):
|
| 482 |
+
"""
|
| 483 |
+
Regression test for issue #34
|
| 484 |
+
|
| 485 |
+
:type tmpdir: py._path.local.LocalPath
|
| 486 |
+
"""
|
| 487 |
+
|
| 488 |
+
NUM = 100
|
| 489 |
+
path = str(tmpdir.join('db.json'))
|
| 490 |
+
|
| 491 |
+
with TinyDB(path) as _db:
|
| 492 |
+
_db.insert_multiple({'i': i} for i in range(NUM))
|
| 493 |
+
|
| 494 |
+
with TinyDB(path) as _db:
|
| 495 |
+
assert _db._get_next_id() - 1 == NUM
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
def test_doc_ids_json(tmpdir):
|
| 499 |
+
"""
|
| 500 |
+
Regression test for issue #45
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
path = str(tmpdir.join('db.json'))
|
| 504 |
+
|
| 505 |
+
with TinyDB(path) as _db:
|
| 506 |
+
_db.drop_tables()
|
| 507 |
+
assert _db.insert({'int': 1, 'char': 'a'}) == 1
|
| 508 |
+
assert _db.insert({'int': 1, 'char': 'a'}) == 2
|
| 509 |
+
|
| 510 |
+
_db.drop_tables()
|
| 511 |
+
assert _db.insert_multiple([{'int': 1, 'char': 'a'},
|
| 512 |
+
{'int': 1, 'char': 'b'},
|
| 513 |
+
{'int': 1, 'char': 'c'}]) == [1, 2, 3]
|
| 514 |
+
|
| 515 |
+
assert _db.contains(doc_id=1)
|
| 516 |
+
assert _db.contains(doc_id=2)
|
| 517 |
+
assert not _db.contains(doc_id=88)
|
| 518 |
+
|
| 519 |
+
_db.update({'int': 2}, doc_ids=[1, 2])
|
| 520 |
+
assert _db.count(where('int') == 2) == 2
|
| 521 |
+
|
| 522 |
+
el = _db.all()[0]
|
| 523 |
+
assert _db.get(doc_id=el.doc_id) == el
|
| 524 |
+
assert _db.get(doc_id=float('NaN')) is None
|
| 525 |
+
|
| 526 |
+
_db.remove(doc_ids=[1, 2])
|
| 527 |
+
assert len(_db) == 1
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
def test_insert_string(tmpdir):
|
| 531 |
+
path = str(tmpdir.join('db.json'))
|
| 532 |
+
|
| 533 |
+
with TinyDB(path) as _db:
|
| 534 |
+
data = [{'int': 1}, {'int': 2}]
|
| 535 |
+
_db.insert_multiple(data)
|
| 536 |
+
|
| 537 |
+
with pytest.raises(ValueError):
|
| 538 |
+
_db.insert([1, 2, 3]) # Fails
|
| 539 |
+
|
| 540 |
+
with pytest.raises(ValueError):
|
| 541 |
+
_db.insert({'bark'}) # Fails
|
| 542 |
+
|
| 543 |
+
assert data == _db.all()
|
| 544 |
+
|
| 545 |
+
_db.insert({'int': 3}) # Does not fail
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
def test_insert_invalid_dict(tmpdir):
|
| 549 |
+
path = str(tmpdir.join('db.json'))
|
| 550 |
+
|
| 551 |
+
with TinyDB(path) as _db:
|
| 552 |
+
data = [{'int': 1}, {'int': 2}]
|
| 553 |
+
_db.insert_multiple(data)
|
| 554 |
+
|
| 555 |
+
with pytest.raises(TypeError):
|
| 556 |
+
_db.insert({'int': _db}) # Fails
|
| 557 |
+
|
| 558 |
+
assert data == _db.all()
|
| 559 |
+
|
| 560 |
+
_db.insert({'int': 3}) # Does not fail
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
def test_gc(tmpdir):
|
| 564 |
+
# See https://github.com/msiemens/tinydb/issues/92
|
| 565 |
+
path = str(tmpdir.join('db.json'))
|
| 566 |
+
db = TinyDB(path)
|
| 567 |
+
table = db.table('foo')
|
| 568 |
+
table.insert({'something': 'else'})
|
| 569 |
+
table.insert({'int': 13})
|
| 570 |
+
assert len(table.search(where('int') == 13)) == 1
|
| 571 |
+
assert table.all() == [{'something': 'else'}, {'int': 13}]
|
| 572 |
+
db.close()
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
def test_drop_table():
|
| 576 |
+
db = TinyDB(storage=MemoryStorage)
|
| 577 |
+
default_table_name = db.table(db.default_table_name).name
|
| 578 |
+
|
| 579 |
+
assert [] == list(db.tables())
|
| 580 |
+
db.drop_table(default_table_name)
|
| 581 |
+
|
| 582 |
+
db.insert({'a': 1})
|
| 583 |
+
assert [default_table_name] == list(db.tables())
|
| 584 |
+
|
| 585 |
+
db.drop_table(default_table_name)
|
| 586 |
+
assert [] == list(db.tables())
|
| 587 |
+
|
| 588 |
+
table_name = 'some-other-table'
|
| 589 |
+
db = TinyDB(storage=MemoryStorage)
|
| 590 |
+
db.table(table_name).insert({'a': 1})
|
| 591 |
+
assert {table_name} == db.tables()
|
| 592 |
+
|
| 593 |
+
db.drop_table(table_name)
|
| 594 |
+
assert set() == db.tables()
|
| 595 |
+
assert table_name not in db._tables
|
| 596 |
+
|
| 597 |
+
db.drop_table('non-existent-table-name')
|
| 598 |
+
assert set() == db.tables()
|
| 599 |
+
|
| 600 |
+
|
| 601 |
+
def test_empty_write(tmpdir):
|
| 602 |
+
path = str(tmpdir.join('db.json'))
|
| 603 |
+
|
| 604 |
+
class ReadOnlyMiddleware(Middleware):
|
| 605 |
+
def write(self, data):
|
| 606 |
+
raise AssertionError('No write for unchanged db')
|
| 607 |
+
|
| 608 |
+
TinyDB(path).close()
|
| 609 |
+
TinyDB(path, storage=ReadOnlyMiddleware(JSONStorage)).close()
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
def test_query_cache():
|
| 613 |
+
db = TinyDB(storage=MemoryStorage)
|
| 614 |
+
db.insert_multiple([
|
| 615 |
+
{'name': 'foo', 'value': 42},
|
| 616 |
+
{'name': 'bar', 'value': -1337}
|
| 617 |
+
])
|
| 618 |
+
|
| 619 |
+
query = where('value') > 0
|
| 620 |
+
|
| 621 |
+
results = db.search(query)
|
| 622 |
+
assert len(results) == 1
|
| 623 |
+
|
| 624 |
+
# Modify the db instance to not return any results when
|
| 625 |
+
# bypassing the query cache
|
| 626 |
+
db._tables[db.table(db.default_table_name).name]._read_table = lambda: {}
|
| 627 |
+
|
| 628 |
+
# Make sure we got an independent copy of the result list
|
| 629 |
+
results.extend([1])
|
| 630 |
+
assert db.search(query) == [{'name': 'foo', 'value': 42}]
|
| 631 |
+
|
| 632 |
+
|
| 633 |
+
def test_tinydb_is_iterable(db: TinyDB):
|
| 634 |
+
assert [r for r in db] == db.all()
|
| 635 |
+
|
| 636 |
+
|
| 637 |
+
def test_repr(tmpdir):
|
| 638 |
+
path = str(tmpdir.join('db.json'))
|
| 639 |
+
|
| 640 |
+
db = TinyDB(path)
|
| 641 |
+
db.insert({'a': 1})
|
| 642 |
+
|
| 643 |
+
assert re.match(
|
| 644 |
+
r"<TinyDB "
|
| 645 |
+
r"tables=\[u?\'_default\'\], "
|
| 646 |
+
r"tables_count=1, "
|
| 647 |
+
r"default_table_documents_count=1, "
|
| 648 |
+
r"all_tables_documents_count=\[\'_default=1\'\]>",
|
| 649 |
+
repr(db))
|
| 650 |
+
|
| 651 |
+
|
| 652 |
+
def test_delete(tmpdir):
|
| 653 |
+
path = str(tmpdir.join('db.json'))
|
| 654 |
+
|
| 655 |
+
db = TinyDB(path, ensure_ascii=False)
|
| 656 |
+
q = Query()
|
| 657 |
+
db.insert({'network': {'id': '114', 'name': 'ok', 'rpc': 'dac',
|
| 658 |
+
'ticker': 'mkay'}})
|
| 659 |
+
assert db.search(q.network.id == '114') == [
|
| 660 |
+
{'network': {'id': '114', 'name': 'ok', 'rpc': 'dac',
|
| 661 |
+
'ticker': 'mkay'}}
|
| 662 |
+
]
|
| 663 |
+
db.remove(q.network.id == '114')
|
| 664 |
+
assert db.search(q.network.id == '114') == []
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
def test_insert_multiple_with_single_dict(db: TinyDB):
|
| 668 |
+
with pytest.raises(ValueError):
|
| 669 |
+
d = {'first': 'John', 'last': 'smith'}
|
| 670 |
+
db.insert_multiple(d) # type: ignore
|
| 671 |
+
db.close()
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
def test_access_storage():
|
| 675 |
+
assert isinstance(TinyDB(storage=MemoryStorage).storage,
|
| 676 |
+
MemoryStorage)
|
| 677 |
+
assert isinstance(TinyDB(storage=CachingMiddleware(MemoryStorage)).storage,
|
| 678 |
+
CachingMiddleware)
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
def test_empty_db_len():
|
| 682 |
+
db = TinyDB(storage=MemoryStorage)
|
| 683 |
+
assert len(db) == 0
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
def test_insert_on_existing_db(tmpdir):
|
| 687 |
+
path = str(tmpdir.join('db.json'))
|
| 688 |
+
|
| 689 |
+
db = TinyDB(path, ensure_ascii=False)
|
| 690 |
+
db.insert({'foo': 'bar'})
|
| 691 |
+
|
| 692 |
+
assert len(db) == 1
|
| 693 |
+
|
| 694 |
+
db.close()
|
| 695 |
+
|
| 696 |
+
db = TinyDB(path, ensure_ascii=False)
|
| 697 |
+
db.insert({'foo': 'bar'})
|
| 698 |
+
db.insert({'foo': 'bar'})
|
| 699 |
+
|
| 700 |
+
assert len(db) == 3
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
def test_storage_access():
|
| 704 |
+
db = TinyDB(storage=MemoryStorage)
|
| 705 |
+
|
| 706 |
+
assert isinstance(db.storage, MemoryStorage)
|
| 707 |
+
|
| 708 |
+
|
| 709 |
+
def test_lambda_query():
|
| 710 |
+
db = TinyDB(storage=MemoryStorage)
|
| 711 |
+
db.insert({'foo': 'bar'})
|
| 712 |
+
|
| 713 |
+
query = lambda doc: doc.get('foo') == 'bar'
|
| 714 |
+
query.is_cacheable = lambda: False
|
| 715 |
+
assert db.search(query) == [{'foo': 'bar'}]
|
| 716 |
+
assert not db._query_cache
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/tests/trusted/tests/test_utils.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from tinydb.utils import LRUCache, freeze, FrozenDict
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_lru_cache():
|
| 7 |
+
cache = LRUCache(capacity=3)
|
| 8 |
+
cache["a"] = 1
|
| 9 |
+
cache["b"] = 2
|
| 10 |
+
cache["c"] = 3
|
| 11 |
+
_ = cache["a"] # move to front in lru queue
|
| 12 |
+
cache["d"] = 4 # move oldest item out of lru queue
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
_ = cache['f']
|
| 16 |
+
except KeyError:
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
assert cache.lru == ["c", "a", "d"]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def test_lru_cache_set_multiple():
|
| 23 |
+
cache = LRUCache(capacity=3)
|
| 24 |
+
cache["a"] = 1
|
| 25 |
+
cache["a"] = 2
|
| 26 |
+
cache["a"] = 3
|
| 27 |
+
cache["a"] = 4
|
| 28 |
+
|
| 29 |
+
assert cache.lru == ["a"]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_lru_cache_set_update():
|
| 33 |
+
cache = LRUCache(capacity=3)
|
| 34 |
+
cache["a"] = 1
|
| 35 |
+
cache["a"] = 2
|
| 36 |
+
|
| 37 |
+
assert cache["a"] == 2
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def test_lru_cache_get():
|
| 41 |
+
cache = LRUCache(capacity=3)
|
| 42 |
+
cache["a"] = 1
|
| 43 |
+
cache["b"] = 1
|
| 44 |
+
cache["c"] = 1
|
| 45 |
+
cache.get("a")
|
| 46 |
+
cache["d"] = 4
|
| 47 |
+
|
| 48 |
+
assert cache.lru == ["c", "a", "d"]
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def test_lru_cache_delete():
|
| 52 |
+
cache = LRUCache(capacity=3)
|
| 53 |
+
cache["a"] = 1
|
| 54 |
+
cache["b"] = 2
|
| 55 |
+
del cache["a"]
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
del cache['f']
|
| 59 |
+
except KeyError:
|
| 60 |
+
pass
|
| 61 |
+
|
| 62 |
+
assert cache.lru == ["b"]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def test_lru_cache_clear():
|
| 66 |
+
cache = LRUCache(capacity=3)
|
| 67 |
+
cache["a"] = 1
|
| 68 |
+
cache["b"] = 2
|
| 69 |
+
cache.clear()
|
| 70 |
+
|
| 71 |
+
assert cache.lru == []
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_lru_cache_unlimited():
|
| 75 |
+
cache = LRUCache()
|
| 76 |
+
for i in range(100):
|
| 77 |
+
cache[i] = i
|
| 78 |
+
|
| 79 |
+
assert len(cache.lru) == 100
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def test_lru_cache_unlimited_explicit():
|
| 83 |
+
cache = LRUCache(capacity=None)
|
| 84 |
+
for i in range(100):
|
| 85 |
+
cache[i] = i
|
| 86 |
+
|
| 87 |
+
assert len(cache.lru) == 100
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def test_lru_cache_iteration_works():
|
| 91 |
+
cache = LRUCache()
|
| 92 |
+
count = 0
|
| 93 |
+
for _ in cache:
|
| 94 |
+
assert False, 'there should be no elements in the cache'
|
| 95 |
+
|
| 96 |
+
assert count == 0
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def test_freeze():
|
| 100 |
+
frozen = freeze([0, 1, 2, {'a': [1, 2, 3]}, {1, 2}])
|
| 101 |
+
assert isinstance(frozen, tuple)
|
| 102 |
+
assert isinstance(frozen[3], FrozenDict)
|
| 103 |
+
assert isinstance(frozen[3]['a'], tuple)
|
| 104 |
+
assert isinstance(frozen[4], frozenset)
|
| 105 |
+
|
| 106 |
+
with pytest.raises(TypeError):
|
| 107 |
+
frozen[0] = 10
|
| 108 |
+
|
| 109 |
+
with pytest.raises(TypeError):
|
| 110 |
+
frozen[3]['a'] = 10
|
| 111 |
+
|
| 112 |
+
with pytest.raises(TypeError):
|
| 113 |
+
frozen[3].pop('a')
|
| 114 |
+
|
| 115 |
+
with pytest.raises(TypeError):
|
| 116 |
+
frozen[3].update({'a': 9})
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/validation/canaries/original-bug.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
:
|
tasks/msiemens__tinydb.10644a0e.func_basic__4550j9d7/validation/openenv.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"canaries": "validation/canaries",
|
| 3 |
+
"profile": "harbor-semantic-v1",
|
| 4 |
+
"requires_credentials": false,
|
| 5 |
+
"resources": {
|
| 6 |
+
"cpu": 2,
|
| 7 |
+
"disk_mb": 16384,
|
| 8 |
+
"episode_timeout_s": 1800,
|
| 9 |
+
"memory_mb": 8192
|
| 10 |
+
},
|
| 11 |
+
"reward": {
|
| 12 |
+
"floor_margin": 0.1,
|
| 13 |
+
"oracle_tolerance": 0,
|
| 14 |
+
"range": [
|
| 15 |
+
0,
|
| 16 |
+
1
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
"reward_key": "reward",
|
| 20 |
+
"types": {
|
| 21 |
+
"tags": [
|
| 22 |
+
"swe",
|
| 23 |
+
"python",
|
| 24 |
+
"mutation-repair"
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/LICENSE.source
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (C) 2013 Markus Siemens <markus@m-siemens.de>
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 4 |
+
|
| 5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/adapter.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.",
|
| 3 |
+
"collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59",
|
| 4 |
+
"dependency_installation_pinned": false,
|
| 5 |
+
"dependency_setup_sha256": "0551e0806afd99add5cb7c6184a7e0b4813c16aa421c4031e64e7e3a27b44236",
|
| 6 |
+
"gold_patch_sha256": "fb64de0dda930e2063f7dd19d6d8ab3be58becf523f9e36969336c6507f7c614",
|
| 7 |
+
"hostile_code_isolation_established": false,
|
| 8 |
+
"known_wrong_semantic_implementations": 0,
|
| 9 |
+
"native_inventory_sha256": "1321b345493830ea5acb9fe9b46c069c51a8ac16e3456ae5a5c50529491a9171",
|
| 10 |
+
"new_files_deletions_and_executable_modes_supported": true,
|
| 11 |
+
"official_profile": {
|
| 12 |
+
"eval_sets": [],
|
| 13 |
+
"profile_class": "Tinydb10644a0e",
|
| 14 |
+
"profile_lines": [
|
| 15 |
+
1020,
|
| 16 |
+
1023
|
| 17 |
+
],
|
| 18 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 19 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 20 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 21 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 22 |
+
"upstream_repo": "msiemens/tinydb"
|
| 23 |
+
},
|
| 24 |
+
"original_bug_canary_nop_equivalent": true,
|
| 25 |
+
"original_bug_runtime_wrongness_established": false,
|
| 26 |
+
"partial_repair_canary": false,
|
| 27 |
+
"partial_repair_sha256": null,
|
| 28 |
+
"partial_repair_wrongness_established": false,
|
| 29 |
+
"provided_original_bug_control": true,
|
| 30 |
+
"repo_url": "https://github.com/swesmith/msiemens__tinydb.10644a0e.git",
|
| 31 |
+
"runtime_image": null,
|
| 32 |
+
"runtime_ready": false,
|
| 33 |
+
"runtime_recipe": {
|
| 34 |
+
"dependency_installation_pinned": false,
|
| 35 |
+
"official_install_cmds": [
|
| 36 |
+
"python -m pip install -e ."
|
| 37 |
+
],
|
| 38 |
+
"official_pytest_argv": [
|
| 39 |
+
"pytest",
|
| 40 |
+
"--disable-warnings",
|
| 41 |
+
"--color=no",
|
| 42 |
+
"--tb=no",
|
| 43 |
+
"--verbose"
|
| 44 |
+
],
|
| 45 |
+
"official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose",
|
| 46 |
+
"panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.",
|
| 47 |
+
"python_version": "3.10",
|
| 48 |
+
"source_bound_test_dependency_cmds": [
|
| 49 |
+
"python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'"
|
| 50 |
+
],
|
| 51 |
+
"test_dependency_source_sha256": {
|
| 52 |
+
"pyproject.toml": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be",
|
| 53 |
+
"pytest.ini": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"runtime_resource_review_required": false,
|
| 57 |
+
"schema": "python-git-patch-jobs-v1",
|
| 58 |
+
"source_base_commit": "32c86a9a38b67bcba98424fa13fb2d1c116e3ac6",
|
| 59 |
+
"source_completion_sha256": "c0ac620a8360881c6ebfcdabc65648f60a852ebe1634d84fa9e21a8f0eb17a02",
|
| 60 |
+
"source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876",
|
| 61 |
+
"source_pr_url": null,
|
| 62 |
+
"source_record": {
|
| 63 |
+
"anti_training_canary": false,
|
| 64 |
+
"anti_training_reviewed": true,
|
| 65 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 66 |
+
"cloud_launch_ready": false,
|
| 67 |
+
"eligibility": {
|
| 68 |
+
"reasons": [],
|
| 69 |
+
"semantic_nonoverlap_established": false,
|
| 70 |
+
"status": "eligible_for_controls",
|
| 71 |
+
"training_admissible": false,
|
| 72 |
+
"warnings": []
|
| 73 |
+
},
|
| 74 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 75 |
+
"instruction_sha256": "7440c35132e4ab53105cfc55bdc3581158a0b90bc463de06862ffe4eabfc6bcd",
|
| 76 |
+
"is_fork": true,
|
| 77 |
+
"learner_path": "tasks/861ff22633f62d146ef5c43c/learner",
|
| 78 |
+
"license_evidence": {
|
| 79 |
+
"source_code": {
|
| 80 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 81 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 82 |
+
"reviewed": true,
|
| 83 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 84 |
+
"spdx": "MIT",
|
| 85 |
+
"training_allowed": true,
|
| 86 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/32c86a9a38b67bcba98424fa13fb2d1c116e3ac6/LICENSE"
|
| 87 |
+
},
|
| 88 |
+
"task_bundle": {
|
| 89 |
+
"reviewed": true,
|
| 90 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 91 |
+
"spdx": "MIT",
|
| 92 |
+
"training_allowed": true,
|
| 93 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 97 |
+
"patch_sha256": "2a6ee925c9360d16d414592679953e7d200120bd6c135c311e2167530548cab6",
|
| 98 |
+
"provenance_path": "tasks/861ff22633f62d146ef5c43c/source-proof.json",
|
| 99 |
+
"repository_lineage": [
|
| 100 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 101 |
+
"msiemens/tinydb"
|
| 102 |
+
],
|
| 103 |
+
"rfc008_complete": false,
|
| 104 |
+
"runtime_qualified": false,
|
| 105 |
+
"semantic_nonoverlap_established": false,
|
| 106 |
+
"source_commit": "32c86a9a38b67bcba98424fa13fb2d1c116e3ac6",
|
| 107 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 108 |
+
"source_head_commit": "32f4d0afbec2910dbddee3574bb37f8b7abbbc0f",
|
| 109 |
+
"source_kind": "mutation",
|
| 110 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 111 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 112 |
+
"source_split": "train",
|
| 113 |
+
"target_model_calibrated": false,
|
| 114 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 115 |
+
"task_sha256": "95bced34b63271a13f92efbad39c5d3ac76017f19cd62719f727b028dfa9b007",
|
| 116 |
+
"training_admissible": false,
|
| 117 |
+
"upstream_identity_reviewed": true,
|
| 118 |
+
"upstream_repo": "msiemens/tinydb",
|
| 119 |
+
"usage": "quarantine_only"
|
| 120 |
+
},
|
| 121 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 122 |
+
"symlink_submodule_changes_supported": false,
|
| 123 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 124 |
+
"transfer": "index-independent-worktree-to-Git-binary-patch",
|
| 125 |
+
"transfer_path": "/testbed/submission.patch",
|
| 126 |
+
"upstream_repo": "msiemens/tinydb"
|
| 127 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/dependency-setup.sh
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
source /opt/miniconda3/bin/activate
|
| 4 |
+
conda activate testbed
|
| 5 |
+
cd /testbed/repo
|
| 6 |
+
python -c 'import sys; assert sys.version_info[:2] == (3, 10)'
|
| 7 |
+
/usr/bin/sha256sum --check <<'OPENENV_NATIVE_TEST_REQUIREMENT'
|
| 8 |
+
4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be pyproject.toml
|
| 9 |
+
OPENENV_NATIVE_TEST_REQUIREMENT
|
| 10 |
+
python -m pip install -e .
|
| 11 |
+
python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'
|
| 12 |
+
|
| 13 |
+
cat > /tmp/openenv-tinydb-yaml.txt <<'OPENENV_PYYAML_PIN'
|
| 14 |
+
PyYAML==6.0.3 --hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b
|
| 15 |
+
OPENENV_PYYAML_PIN
|
| 16 |
+
python -m pip install --no-deps --only-binary=:all: --require-hashes --index-url https://pypi.org/simple -r /tmp/openenv-tinydb-yaml.txt
|
| 17 |
+
python -c 'import yaml; assert yaml.__version__ == "6.0.3"'
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Runtime is selected only by an independently qualified immutable amd64 receipt.
|
| 2 |
+
FROM ubuntu:22.04
|
| 3 |
+
RUN false
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/instruction.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
JSONStorage ignores custom json.dumps kwargs
|
| 2 |
+
|
| 3 |
+
#### Description
|
| 4 |
+
|
| 5 |
+
When using JSONStorage with custom kwargs for json.dumps (like `sort_keys`, `indent`, etc.), the kwargs are being ignored and not passed to the json.dumps call.
|
| 6 |
+
|
| 7 |
+
#### Steps/Code to Reproduce
|
| 8 |
+
|
| 9 |
+
```python
|
| 10 |
+
from tinydb import TinyDB
|
| 11 |
+
import tempfile
|
| 12 |
+
import os
|
| 13 |
+
|
| 14 |
+
# Create a temporary database file
|
| 15 |
+
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json') as f:
|
| 16 |
+
db_path = f.name
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
# Initialize TinyDB with custom JSON formatting
|
| 20 |
+
db = TinyDB(db_path, sort_keys=True, indent=4, separators=(',', ': '))
|
| 21 |
+
db.insert({'b': 1})
|
| 22 |
+
db.insert({'a': 1})
|
| 23 |
+
db.close()
|
| 24 |
+
|
| 25 |
+
# Read the file content
|
| 26 |
+
with open(db_path, 'r') as f:
|
| 27 |
+
content = f.read()
|
| 28 |
+
|
| 29 |
+
print("Actual output:")
|
| 30 |
+
print(repr(content))
|
| 31 |
+
print("\nExpected formatted JSON with indentation and sorted keys")
|
| 32 |
+
|
| 33 |
+
finally:
|
| 34 |
+
os.unlink(db_path)
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
The database file should contain properly formatted JSON with sorted keys and indentation, but instead it contains minified JSON without the custom formatting.
|
| 38 |
+
|
| 39 |
+
## Environment
|
| 40 |
+
|
| 41 |
+
The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest <tests>`. Don't install packages: the tests need nothing else, and the sandbox may have no network access.
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/metadata.json
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"all_runtime_and_training_flags": false,
|
| 3 |
+
"official_profile": {
|
| 4 |
+
"eval_sets": [],
|
| 5 |
+
"profile_class": "Tinydb10644a0e",
|
| 6 |
+
"profile_lines": [
|
| 7 |
+
1020,
|
| 8 |
+
1023
|
| 9 |
+
],
|
| 10 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 11 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 12 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 13 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 14 |
+
"upstream_repo": "msiemens/tinydb"
|
| 15 |
+
},
|
| 16 |
+
"source_healthy_reference_proof": {
|
| 17 |
+
"FAIL_TO_PASS": [
|
| 18 |
+
"tests/test_storages.py::test_json_kwargs",
|
| 19 |
+
"tests/test_tinydb.py::test_insert_invalid_dict"
|
| 20 |
+
],
|
| 21 |
+
"PASS_TO_PASS": [
|
| 22 |
+
"tests/test_middlewares.py::test_caching",
|
| 23 |
+
"tests/test_middlewares.py::test_caching_read",
|
| 24 |
+
"tests/test_middlewares.py::test_caching_write_many",
|
| 25 |
+
"tests/test_middlewares.py::test_caching_flush",
|
| 26 |
+
"tests/test_middlewares.py::test_caching_flush_manually",
|
| 27 |
+
"tests/test_middlewares.py::test_caching_write",
|
| 28 |
+
"tests/test_middlewares.py::test_nested",
|
| 29 |
+
"tests/test_middlewares.py::test_caching_json_write",
|
| 30 |
+
"tests/test_operations.py::test_delete[memory]",
|
| 31 |
+
"tests/test_operations.py::test_delete[json]",
|
| 32 |
+
"tests/test_operations.py::test_add_int[memory]",
|
| 33 |
+
"tests/test_operations.py::test_add_int[json]",
|
| 34 |
+
"tests/test_operations.py::test_add_str[memory]",
|
| 35 |
+
"tests/test_operations.py::test_add_str[json]",
|
| 36 |
+
"tests/test_operations.py::test_subtract[memory]",
|
| 37 |
+
"tests/test_operations.py::test_subtract[json]",
|
| 38 |
+
"tests/test_operations.py::test_set[memory]",
|
| 39 |
+
"tests/test_operations.py::test_set[json]",
|
| 40 |
+
"tests/test_operations.py::test_increment[memory]",
|
| 41 |
+
"tests/test_operations.py::test_increment[json]",
|
| 42 |
+
"tests/test_operations.py::test_decrement[memory]",
|
| 43 |
+
"tests/test_operations.py::test_decrement[json]",
|
| 44 |
+
"tests/test_queries.py::test_no_path",
|
| 45 |
+
"tests/test_queries.py::test_path_exists",
|
| 46 |
+
"tests/test_queries.py::test_path_and",
|
| 47 |
+
"tests/test_queries.py::test_callable_in_path_with_map",
|
| 48 |
+
"tests/test_queries.py::test_callable_in_path_with_chain",
|
| 49 |
+
"tests/test_queries.py::test_eq",
|
| 50 |
+
"tests/test_queries.py::test_ne",
|
| 51 |
+
"tests/test_queries.py::test_lt",
|
| 52 |
+
"tests/test_queries.py::test_le",
|
| 53 |
+
"tests/test_queries.py::test_gt",
|
| 54 |
+
"tests/test_queries.py::test_ge",
|
| 55 |
+
"tests/test_queries.py::test_or",
|
| 56 |
+
"tests/test_queries.py::test_and",
|
| 57 |
+
"tests/test_queries.py::test_not",
|
| 58 |
+
"tests/test_queries.py::test_has_key",
|
| 59 |
+
"tests/test_queries.py::test_regex",
|
| 60 |
+
"tests/test_queries.py::test_custom",
|
| 61 |
+
"tests/test_queries.py::test_custom_with_params",
|
| 62 |
+
"tests/test_queries.py::test_any",
|
| 63 |
+
"tests/test_queries.py::test_all",
|
| 64 |
+
"tests/test_queries.py::test_has",
|
| 65 |
+
"tests/test_queries.py::test_one_of",
|
| 66 |
+
"tests/test_queries.py::test_hash",
|
| 67 |
+
"tests/test_queries.py::test_orm_usage",
|
| 68 |
+
"tests/test_queries.py::test_repr",
|
| 69 |
+
"tests/test_queries.py::test_subclass",
|
| 70 |
+
"tests/test_queries.py::test_noop",
|
| 71 |
+
"tests/test_queries.py::test_equality",
|
| 72 |
+
"tests/test_queries.py::test_empty_query_error",
|
| 73 |
+
"tests/test_queries.py::test_fragment",
|
| 74 |
+
"tests/test_queries.py::test_fragment_with_path",
|
| 75 |
+
"tests/test_queries.py::test_get_item",
|
| 76 |
+
"tests/test_storages.py::test_json",
|
| 77 |
+
"tests/test_storages.py::test_json_readwrite",
|
| 78 |
+
"tests/test_storages.py::test_json_read",
|
| 79 |
+
"tests/test_storages.py::test_create_dirs",
|
| 80 |
+
"tests/test_storages.py::test_json_invalid_directory",
|
| 81 |
+
"tests/test_storages.py::test_in_memory",
|
| 82 |
+
"tests/test_storages.py::test_in_memory_close",
|
| 83 |
+
"tests/test_storages.py::test_custom",
|
| 84 |
+
"tests/test_storages.py::test_read_once",
|
| 85 |
+
"tests/test_storages.py::test_custom_with_exception",
|
| 86 |
+
"tests/test_storages.py::test_yaml",
|
| 87 |
+
"tests/test_storages.py::test_encoding",
|
| 88 |
+
"tests/test_tables.py::test_next_id[memory]",
|
| 89 |
+
"tests/test_tables.py::test_next_id[json]",
|
| 90 |
+
"tests/test_tables.py::test_tables_list[memory]",
|
| 91 |
+
"tests/test_tables.py::test_tables_list[json]",
|
| 92 |
+
"tests/test_tables.py::test_one_table[memory]",
|
| 93 |
+
"tests/test_tables.py::test_one_table[json]",
|
| 94 |
+
"tests/test_tables.py::test_multiple_tables[memory]",
|
| 95 |
+
"tests/test_tables.py::test_multiple_tables[json]",
|
| 96 |
+
"tests/test_tables.py::test_caching[memory]",
|
| 97 |
+
"tests/test_tables.py::test_caching[json]",
|
| 98 |
+
"tests/test_tables.py::test_query_cache[memory]",
|
| 99 |
+
"tests/test_tables.py::test_query_cache[json]",
|
| 100 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[memory]",
|
| 101 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[json]",
|
| 102 |
+
"tests/test_tables.py::test_zero_cache_size[memory]",
|
| 103 |
+
"tests/test_tables.py::test_zero_cache_size[json]",
|
| 104 |
+
"tests/test_tables.py::test_query_cache_size[memory]",
|
| 105 |
+
"tests/test_tables.py::test_query_cache_size[json]",
|
| 106 |
+
"tests/test_tables.py::test_lru_cache[memory]",
|
| 107 |
+
"tests/test_tables.py::test_lru_cache[json]",
|
| 108 |
+
"tests/test_tables.py::test_table_is_iterable[memory]",
|
| 109 |
+
"tests/test_tables.py::test_table_is_iterable[json]",
|
| 110 |
+
"tests/test_tables.py::test_table_name[memory]",
|
| 111 |
+
"tests/test_tables.py::test_table_name[json]",
|
| 112 |
+
"tests/test_tables.py::test_table_repr[memory]",
|
| 113 |
+
"tests/test_tables.py::test_table_repr[json]",
|
| 114 |
+
"tests/test_tables.py::test_truncate_table[memory]",
|
| 115 |
+
"tests/test_tables.py::test_truncate_table[json]",
|
| 116 |
+
"tests/test_tables.py::test_persist_table[memory]",
|
| 117 |
+
"tests/test_tables.py::test_persist_table[json]",
|
| 118 |
+
"tests/test_tinydb.py::test_drop_tables[memory]",
|
| 119 |
+
"tests/test_tinydb.py::test_drop_tables[json]",
|
| 120 |
+
"tests/test_tinydb.py::test_all[memory]",
|
| 121 |
+
"tests/test_tinydb.py::test_all[json]",
|
| 122 |
+
"tests/test_tinydb.py::test_insert[memory]",
|
| 123 |
+
"tests/test_tinydb.py::test_insert[json]",
|
| 124 |
+
"tests/test_tinydb.py::test_insert_ids[memory]",
|
| 125 |
+
"tests/test_tinydb.py::test_insert_ids[json]",
|
| 126 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[memory]",
|
| 127 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[json]",
|
| 128 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[memory]",
|
| 129 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[json]",
|
| 130 |
+
"tests/test_tinydb.py::test_insert_multiple[memory]",
|
| 131 |
+
"tests/test_tinydb.py::test_insert_multiple[json]",
|
| 132 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[memory]",
|
| 133 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[json]",
|
| 134 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[memory]",
|
| 135 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[json]",
|
| 136 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[memory]",
|
| 137 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[json]",
|
| 138 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[memory]",
|
| 139 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[json]",
|
| 140 |
+
"tests/test_tinydb.py::test_custom_mapping_type_with_json",
|
| 141 |
+
"tests/test_tinydb.py::test_remove[memory]",
|
| 142 |
+
"tests/test_tinydb.py::test_remove[json]",
|
| 143 |
+
"tests/test_tinydb.py::test_remove_all_fails[memory]",
|
| 144 |
+
"tests/test_tinydb.py::test_remove_all_fails[json]",
|
| 145 |
+
"tests/test_tinydb.py::test_remove_multiple[memory]",
|
| 146 |
+
"tests/test_tinydb.py::test_remove_multiple[json]",
|
| 147 |
+
"tests/test_tinydb.py::test_remove_ids[memory]",
|
| 148 |
+
"tests/test_tinydb.py::test_remove_ids[json]",
|
| 149 |
+
"tests/test_tinydb.py::test_remove_returns_ids[memory]",
|
| 150 |
+
"tests/test_tinydb.py::test_remove_returns_ids[json]",
|
| 151 |
+
"tests/test_tinydb.py::test_update[memory]",
|
| 152 |
+
"tests/test_tinydb.py::test_update[json]",
|
| 153 |
+
"tests/test_tinydb.py::test_update_all[memory]",
|
| 154 |
+
"tests/test_tinydb.py::test_update_all[json]",
|
| 155 |
+
"tests/test_tinydb.py::test_update_returns_ids[memory]",
|
| 156 |
+
"tests/test_tinydb.py::test_update_returns_ids[json]",
|
| 157 |
+
"tests/test_tinydb.py::test_update_transform[memory]",
|
| 158 |
+
"tests/test_tinydb.py::test_update_transform[json]",
|
| 159 |
+
"tests/test_tinydb.py::test_update_ids[memory]",
|
| 160 |
+
"tests/test_tinydb.py::test_update_ids[json]",
|
| 161 |
+
"tests/test_tinydb.py::test_update_multiple[memory]",
|
| 162 |
+
"tests/test_tinydb.py::test_update_multiple[json]",
|
| 163 |
+
"tests/test_tinydb.py::test_update_multiple_operation[memory]",
|
| 164 |
+
"tests/test_tinydb.py::test_update_multiple_operation[json]",
|
| 165 |
+
"tests/test_tinydb.py::test_upsert[memory]",
|
| 166 |
+
"tests/test_tinydb.py::test_upsert[json]",
|
| 167 |
+
"tests/test_tinydb.py::test_upsert_by_id[memory]",
|
| 168 |
+
"tests/test_tinydb.py::test_upsert_by_id[json]",
|
| 169 |
+
"tests/test_tinydb.py::test_search[memory]",
|
| 170 |
+
"tests/test_tinydb.py::test_search[json]",
|
| 171 |
+
"tests/test_tinydb.py::test_search_path[memory]",
|
| 172 |
+
"tests/test_tinydb.py::test_search_path[json]",
|
| 173 |
+
"tests/test_tinydb.py::test_search_no_results_cache[memory]",
|
| 174 |
+
"tests/test_tinydb.py::test_search_no_results_cache[json]",
|
| 175 |
+
"tests/test_tinydb.py::test_get[memory]",
|
| 176 |
+
"tests/test_tinydb.py::test_get[json]",
|
| 177 |
+
"tests/test_tinydb.py::test_get_ids[memory]",
|
| 178 |
+
"tests/test_tinydb.py::test_get_ids[json]",
|
| 179 |
+
"tests/test_tinydb.py::test_get_multiple_ids[memory]",
|
| 180 |
+
"tests/test_tinydb.py::test_get_multiple_ids[json]",
|
| 181 |
+
"tests/test_tinydb.py::test_get_invalid[memory]",
|
| 182 |
+
"tests/test_tinydb.py::test_get_invalid[json]",
|
| 183 |
+
"tests/test_tinydb.py::test_count[memory]",
|
| 184 |
+
"tests/test_tinydb.py::test_count[json]",
|
| 185 |
+
"tests/test_tinydb.py::test_contains[memory]",
|
| 186 |
+
"tests/test_tinydb.py::test_contains[json]",
|
| 187 |
+
"tests/test_tinydb.py::test_contains_ids[memory]",
|
| 188 |
+
"tests/test_tinydb.py::test_contains_ids[json]",
|
| 189 |
+
"tests/test_tinydb.py::test_contains_invalid[memory]",
|
| 190 |
+
"tests/test_tinydb.py::test_contains_invalid[json]",
|
| 191 |
+
"tests/test_tinydb.py::test_get_idempotent[memory]",
|
| 192 |
+
"tests/test_tinydb.py::test_get_idempotent[json]",
|
| 193 |
+
"tests/test_tinydb.py::test_multiple_dbs",
|
| 194 |
+
"tests/test_tinydb.py::test_storage_closed_once",
|
| 195 |
+
"tests/test_tinydb.py::test_unique_ids",
|
| 196 |
+
"tests/test_tinydb.py::test_lastid_after_open",
|
| 197 |
+
"tests/test_tinydb.py::test_doc_ids_json",
|
| 198 |
+
"tests/test_tinydb.py::test_insert_string",
|
| 199 |
+
"tests/test_tinydb.py::test_gc",
|
| 200 |
+
"tests/test_tinydb.py::test_drop_table",
|
| 201 |
+
"tests/test_tinydb.py::test_empty_write",
|
| 202 |
+
"tests/test_tinydb.py::test_query_cache",
|
| 203 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[memory]",
|
| 204 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[json]",
|
| 205 |
+
"tests/test_tinydb.py::test_repr",
|
| 206 |
+
"tests/test_tinydb.py::test_delete",
|
| 207 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[memory]",
|
| 208 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[json]",
|
| 209 |
+
"tests/test_tinydb.py::test_access_storage",
|
| 210 |
+
"tests/test_tinydb.py::test_empty_db_len",
|
| 211 |
+
"tests/test_tinydb.py::test_insert_on_existing_db",
|
| 212 |
+
"tests/test_tinydb.py::test_storage_access",
|
| 213 |
+
"tests/test_tinydb.py::test_lambda_query",
|
| 214 |
+
"tests/test_utils.py::test_lru_cache",
|
| 215 |
+
"tests/test_utils.py::test_lru_cache_set_multiple",
|
| 216 |
+
"tests/test_utils.py::test_lru_cache_set_update",
|
| 217 |
+
"tests/test_utils.py::test_lru_cache_get",
|
| 218 |
+
"tests/test_utils.py::test_lru_cache_delete",
|
| 219 |
+
"tests/test_utils.py::test_lru_cache_clear",
|
| 220 |
+
"tests/test_utils.py::test_lru_cache_unlimited",
|
| 221 |
+
"tests/test_utils.py::test_lru_cache_unlimited_explicit",
|
| 222 |
+
"tests/test_utils.py::test_lru_cache_iteration_works",
|
| 223 |
+
"tests/test_utils.py::test_freeze"
|
| 224 |
+
],
|
| 225 |
+
"all_git_blobs_modes_verified": true,
|
| 226 |
+
"cloud_launch_ready": false,
|
| 227 |
+
"commits": {
|
| 228 |
+
"bug": "32f4d0afbec2910dbddee3574bb37f8b7abbbc0f",
|
| 229 |
+
"healthy": "278700580526dd378f18f40b641885ec78df63e1",
|
| 230 |
+
"learner": "32c86a9a38b67bcba98424fa13fb2d1c116e3ac6"
|
| 231 |
+
},
|
| 232 |
+
"existing_squirrel_snapshot_reused": false,
|
| 233 |
+
"full_transfer_allowlist": [
|
| 234 |
+
"/testbed/.coveragerc",
|
| 235 |
+
"/testbed/.github/stale.yml",
|
| 236 |
+
"/testbed/.gitignore",
|
| 237 |
+
"/testbed/.readthedocs.yml",
|
| 238 |
+
"/testbed/CONTRIBUTING.rst",
|
| 239 |
+
"/testbed/LICENSE",
|
| 240 |
+
"/testbed/MANIFEST.in",
|
| 241 |
+
"/testbed/README.rst",
|
| 242 |
+
"/testbed/artwork/logo.png",
|
| 243 |
+
"/testbed/artwork/logo.svg",
|
| 244 |
+
"/testbed/docs/.gitignore",
|
| 245 |
+
"/testbed/docs/Makefile",
|
| 246 |
+
"/testbed/docs/_static/logo.png",
|
| 247 |
+
"/testbed/docs/_templates/links.html",
|
| 248 |
+
"/testbed/docs/_templates/sidebarlogo.html",
|
| 249 |
+
"/testbed/docs/_themes/.gitignore",
|
| 250 |
+
"/testbed/docs/_themes/LICENSE",
|
| 251 |
+
"/testbed/docs/_themes/README",
|
| 252 |
+
"/testbed/docs/_themes/flask/layout.html",
|
| 253 |
+
"/testbed/docs/_themes/flask/page.html",
|
| 254 |
+
"/testbed/docs/_themes/flask/relations.html",
|
| 255 |
+
"/testbed/docs/_themes/flask/static/flasky.css_t",
|
| 256 |
+
"/testbed/docs/_themes/flask/theme.conf",
|
| 257 |
+
"/testbed/docs/_themes/flask_theme_support.py",
|
| 258 |
+
"/testbed/docs/api.rst",
|
| 259 |
+
"/testbed/docs/changelog.rst",
|
| 260 |
+
"/testbed/docs/conf.py",
|
| 261 |
+
"/testbed/docs/contribute.rst",
|
| 262 |
+
"/testbed/docs/extend.rst",
|
| 263 |
+
"/testbed/docs/extensions.rst",
|
| 264 |
+
"/testbed/docs/getting-started.rst",
|
| 265 |
+
"/testbed/docs/index.rst",
|
| 266 |
+
"/testbed/docs/intro.rst",
|
| 267 |
+
"/testbed/docs/make.bat",
|
| 268 |
+
"/testbed/docs/upgrade.rst",
|
| 269 |
+
"/testbed/docs/usage.rst",
|
| 270 |
+
"/testbed/mypy.ini",
|
| 271 |
+
"/testbed/poetry.lock",
|
| 272 |
+
"/testbed/pyproject.toml",
|
| 273 |
+
"/testbed/pytest.ini",
|
| 274 |
+
"/testbed/tests/__init__.py",
|
| 275 |
+
"/testbed/tests/conftest.py",
|
| 276 |
+
"/testbed/tests/test_middlewares.py",
|
| 277 |
+
"/testbed/tests/test_operations.py",
|
| 278 |
+
"/testbed/tests/test_queries.py",
|
| 279 |
+
"/testbed/tests/test_tables.py",
|
| 280 |
+
"/testbed/tests/test_utils.py",
|
| 281 |
+
"/testbed/tinydb/__init__.py",
|
| 282 |
+
"/testbed/tinydb/database.py",
|
| 283 |
+
"/testbed/tinydb/middlewares.py",
|
| 284 |
+
"/testbed/tinydb/mypy_plugin.py",
|
| 285 |
+
"/testbed/tinydb/operations.py",
|
| 286 |
+
"/testbed/tinydb/py.typed",
|
| 287 |
+
"/testbed/tinydb/queries.py",
|
| 288 |
+
"/testbed/tinydb/storages.py",
|
| 289 |
+
"/testbed/tinydb/table.py",
|
| 290 |
+
"/testbed/tinydb/utils.py",
|
| 291 |
+
"/testbed/tinydb/version.py"
|
| 292 |
+
],
|
| 293 |
+
"healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed",
|
| 294 |
+
"mutation_matches_dataset_and_git_blobs": true,
|
| 295 |
+
"official_profile": {
|
| 296 |
+
"eval_sets": [],
|
| 297 |
+
"profile_class": "Tinydb10644a0e",
|
| 298 |
+
"profile_lines": [
|
| 299 |
+
1020,
|
| 300 |
+
1023
|
| 301 |
+
],
|
| 302 |
+
"profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f",
|
| 303 |
+
"profile_source_path": "swesmith/profiles/python.py",
|
| 304 |
+
"profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286",
|
| 305 |
+
"upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 306 |
+
"upstream_repo": "msiemens/tinydb"
|
| 307 |
+
},
|
| 308 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 309 |
+
"private_test_paths": [
|
| 310 |
+
"tests/test_storages.py",
|
| 311 |
+
"tests/test_tinydb.py"
|
| 312 |
+
],
|
| 313 |
+
"private_tests_unchanged": true,
|
| 314 |
+
"profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference",
|
| 315 |
+
"qwen_calibrated": false,
|
| 316 |
+
"runtime_qualified": false,
|
| 317 |
+
"source_paths": [
|
| 318 |
+
"tinydb/storages.py"
|
| 319 |
+
],
|
| 320 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 321 |
+
"source_stages_bytes": 932978,
|
| 322 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 323 |
+
"transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter",
|
| 324 |
+
"upstream_repo": "msiemens/tinydb"
|
| 325 |
+
},
|
| 326 |
+
"source_record": {
|
| 327 |
+
"anti_training_canary": false,
|
| 328 |
+
"anti_training_reviewed": true,
|
| 329 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 330 |
+
"cloud_launch_ready": false,
|
| 331 |
+
"eligibility": {
|
| 332 |
+
"reasons": [],
|
| 333 |
+
"semantic_nonoverlap_established": false,
|
| 334 |
+
"status": "eligible_for_controls",
|
| 335 |
+
"training_admissible": false,
|
| 336 |
+
"warnings": []
|
| 337 |
+
},
|
| 338 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 339 |
+
"instruction_sha256": "7440c35132e4ab53105cfc55bdc3581158a0b90bc463de06862ffe4eabfc6bcd",
|
| 340 |
+
"is_fork": true,
|
| 341 |
+
"learner_path": "tasks/861ff22633f62d146ef5c43c/learner",
|
| 342 |
+
"license_evidence": {
|
| 343 |
+
"source_code": {
|
| 344 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 345 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 346 |
+
"reviewed": true,
|
| 347 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 348 |
+
"spdx": "MIT",
|
| 349 |
+
"training_allowed": true,
|
| 350 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/32c86a9a38b67bcba98424fa13fb2d1c116e3ac6/LICENSE"
|
| 351 |
+
},
|
| 352 |
+
"task_bundle": {
|
| 353 |
+
"reviewed": true,
|
| 354 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 355 |
+
"spdx": "MIT",
|
| 356 |
+
"training_allowed": true,
|
| 357 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 358 |
+
}
|
| 359 |
+
},
|
| 360 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 361 |
+
"patch_sha256": "2a6ee925c9360d16d414592679953e7d200120bd6c135c311e2167530548cab6",
|
| 362 |
+
"provenance_path": "tasks/861ff22633f62d146ef5c43c/source-proof.json",
|
| 363 |
+
"repository_lineage": [
|
| 364 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 365 |
+
"msiemens/tinydb"
|
| 366 |
+
],
|
| 367 |
+
"rfc008_complete": false,
|
| 368 |
+
"runtime_qualified": false,
|
| 369 |
+
"semantic_nonoverlap_established": false,
|
| 370 |
+
"source_commit": "32c86a9a38b67bcba98424fa13fb2d1c116e3ac6",
|
| 371 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 372 |
+
"source_head_commit": "32f4d0afbec2910dbddee3574bb37f8b7abbbc0f",
|
| 373 |
+
"source_kind": "mutation",
|
| 374 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 375 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 376 |
+
"source_split": "train",
|
| 377 |
+
"target_model_calibrated": false,
|
| 378 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 379 |
+
"task_sha256": "95bced34b63271a13f92efbad39c5d3ac76017f19cd62719f727b028dfa9b007",
|
| 380 |
+
"training_admissible": false,
|
| 381 |
+
"upstream_identity_reviewed": true,
|
| 382 |
+
"upstream_repo": "msiemens/tinydb",
|
| 383 |
+
"usage": "quarantine_only"
|
| 384 |
+
},
|
| 385 |
+
"task_kind": "original-source-mutation"
|
| 386 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/provenance.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"generated_reference": false,
|
| 3 |
+
"healthy_reference_delta_sha256": "fb64de0dda930e2063f7dd19d6d8ab3be58becf523f9e36969336c6507f7c614",
|
| 4 |
+
"native_pytest_ids_preserved": true,
|
| 5 |
+
"original_source_code_license": {
|
| 6 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 7 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 8 |
+
"reviewed": true,
|
| 9 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 10 |
+
"spdx": "MIT",
|
| 11 |
+
"training_allowed": true,
|
| 12 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/32c86a9a38b67bcba98424fa13fb2d1c116e3ac6/LICENSE"
|
| 13 |
+
},
|
| 14 |
+
"provided_reference": true,
|
| 15 |
+
"qwen_calibrated": false,
|
| 16 |
+
"runtime_qualified": false,
|
| 17 |
+
"source_completion_sha256": "c0ac620a8360881c6ebfcdabc65648f60a852ebe1634d84fa9e21a8f0eb17a02",
|
| 18 |
+
"source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876",
|
| 19 |
+
"source_proof_sha256": "d2c5bf721b7b4b20e7e5a17e1e3b1561bc0591edfc6dd28df13782f4e2b121e4",
|
| 20 |
+
"source_record": {
|
| 21 |
+
"anti_training_canary": false,
|
| 22 |
+
"anti_training_reviewed": true,
|
| 23 |
+
"candidate_id": "swesmith-py:msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 24 |
+
"cloud_launch_ready": false,
|
| 25 |
+
"eligibility": {
|
| 26 |
+
"reasons": [],
|
| 27 |
+
"semantic_nonoverlap_established": false,
|
| 28 |
+
"status": "eligible_for_controls",
|
| 29 |
+
"training_admissible": false,
|
| 30 |
+
"warnings": []
|
| 31 |
+
},
|
| 32 |
+
"healthy_mirror_commit": "278700580526dd378f18f40b641885ec78df63e1",
|
| 33 |
+
"instruction_sha256": "7440c35132e4ab53105cfc55bdc3581158a0b90bc463de06862ffe4eabfc6bcd",
|
| 34 |
+
"is_fork": true,
|
| 35 |
+
"learner_path": "tasks/861ff22633f62d146ef5c43c/learner",
|
| 36 |
+
"license_evidence": {
|
| 37 |
+
"source_code": {
|
| 38 |
+
"actual_upstream_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 39 |
+
"actual_upstream_url": "https://raw.githubusercontent.com/msiemens/tinydb/10644a0e07ad180c5b756aba272ee6b0dbd12df8/LICENSE",
|
| 40 |
+
"reviewed": true,
|
| 41 |
+
"sha256": "b0e2a2d39271e3d96b717d7be8235ac413d74797bf7f742f0801cfaad6c8c912",
|
| 42 |
+
"spdx": "MIT",
|
| 43 |
+
"training_allowed": true,
|
| 44 |
+
"url": "https://raw.githubusercontent.com/swesmith/msiemens__tinydb.10644a0e/32c86a9a38b67bcba98424fa13fb2d1c116e3ac6/LICENSE"
|
| 45 |
+
},
|
| 46 |
+
"task_bundle": {
|
| 47 |
+
"reviewed": true,
|
| 48 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 49 |
+
"spdx": "MIT",
|
| 50 |
+
"training_allowed": true,
|
| 51 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
"original_source_commit": "10644a0e07ad180c5b756aba272ee6b0dbd12df8",
|
| 55 |
+
"patch_sha256": "2a6ee925c9360d16d414592679953e7d200120bd6c135c311e2167530548cab6",
|
| 56 |
+
"provenance_path": "tasks/861ff22633f62d146ef5c43c/source-proof.json",
|
| 57 |
+
"repository_lineage": [
|
| 58 |
+
"swesmith/msiemens__tinydb.10644a0e",
|
| 59 |
+
"msiemens/tinydb"
|
| 60 |
+
],
|
| 61 |
+
"rfc008_complete": false,
|
| 62 |
+
"runtime_qualified": false,
|
| 63 |
+
"semantic_nonoverlap_established": false,
|
| 64 |
+
"source_commit": "32c86a9a38b67bcba98424fa13fb2d1c116e3ac6",
|
| 65 |
+
"source_dataset": "SWE-bench/SWE-smith-py",
|
| 66 |
+
"source_head_commit": "32f4d0afbec2910dbddee3574bb37f8b7abbbc0f",
|
| 67 |
+
"source_kind": "mutation",
|
| 68 |
+
"source_repo": "swesmith/msiemens__tinydb.10644a0e",
|
| 69 |
+
"source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e",
|
| 70 |
+
"source_split": "train",
|
| 71 |
+
"target_model_calibrated": false,
|
| 72 |
+
"task_id": "msiemens__tinydb.10644a0e.func_basic__532t36or",
|
| 73 |
+
"task_sha256": "95bced34b63271a13f92efbad39c5d3ac76017f19cd62719f727b028dfa9b007",
|
| 74 |
+
"training_admissible": false,
|
| 75 |
+
"upstream_identity_reviewed": true,
|
| 76 |
+
"upstream_repo": "msiemens/tinydb",
|
| 77 |
+
"usage": "quarantine_only"
|
| 78 |
+
},
|
| 79 |
+
"task_bundle_license": {
|
| 80 |
+
"reviewed": true,
|
| 81 |
+
"sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808",
|
| 82 |
+
"spdx": "MIT",
|
| 83 |
+
"training_allowed": true,
|
| 84 |
+
"url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md"
|
| 85 |
+
},
|
| 86 |
+
"training_admissible": false,
|
| 87 |
+
"trusted_tests_sha256": "ff9a5ef814fab3aeaea8a510213b4330c9b7600d0e4cd9f29754ec6179c0d458"
|
| 88 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/provided-gold.diff
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/tinydb/storages.py b/tinydb/storages.py
|
| 2 |
+
index b6a7a6391cb0ec0673803e744e5dbfd94b52cf69..d5a2db7804444a430534219838e55fcfeee7d305 100644
|
| 3 |
+
--- a/tinydb/storages.py
|
| 4 |
+
+++ b/tinydb/storages.py
|
| 5 |
+
@@ -136,23 +136,24 @@
|
| 6 |
+
return json.load(self._handle)
|
| 7 |
+
|
| 8 |
+
def write(self, data: Dict[str, Dict[str, Any]]):
|
| 9 |
+
+ # Move the cursor to the beginning of the file just in case
|
| 10 |
+
self._handle.seek(0)
|
| 11 |
+
|
| 12 |
+
- try:
|
| 13 |
+
- serialized = json.dumps(data)
|
| 14 |
+
- except TypeError:
|
| 15 |
+
- raise ValueError('Data is not serializable.')
|
| 16 |
+
+ # Serialize the database state using the user-provided arguments
|
| 17 |
+
+ serialized = json.dumps(data, **self.kwargs)
|
| 18 |
+
|
| 19 |
+
+ # Write the serialized data to the file
|
| 20 |
+
try:
|
| 21 |
+
self._handle.write(serialized)
|
| 22 |
+
except io.UnsupportedOperation:
|
| 23 |
+
raise IOError('Cannot write to the database. Access mode is "{0}"'.format(self._mode))
|
| 24 |
+
|
| 25 |
+
+ # Ensure the file has been written
|
| 26 |
+
self._handle.flush()
|
| 27 |
+
os.fsync(self._handle.fileno())
|
| 28 |
+
|
| 29 |
+
- new_offset = len(serialized)
|
| 30 |
+
- self._handle.seek(new_offset)
|
| 31 |
+
+ # Remove data that is behind the new cursor in case the file has
|
| 32 |
+
+ # gotten shorter
|
| 33 |
+
self._handle.truncate()
|
| 34 |
+
|
| 35 |
+
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/solution/solve.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
cd /testbed/repo
|
| 4 |
+
cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE'
|
| 5 |
+
diff --git a/tinydb/storages.py b/tinydb/storages.py
|
| 6 |
+
index b6a7a6391cb0ec0673803e744e5dbfd94b52cf69..d5a2db7804444a430534219838e55fcfeee7d305 100644
|
| 7 |
+
--- a/tinydb/storages.py
|
| 8 |
+
+++ b/tinydb/storages.py
|
| 9 |
+
@@ -136,23 +136,24 @@
|
| 10 |
+
return json.load(self._handle)
|
| 11 |
+
|
| 12 |
+
def write(self, data: Dict[str, Dict[str, Any]]):
|
| 13 |
+
+ # Move the cursor to the beginning of the file just in case
|
| 14 |
+
self._handle.seek(0)
|
| 15 |
+
|
| 16 |
+
- try:
|
| 17 |
+
- serialized = json.dumps(data)
|
| 18 |
+
- except TypeError:
|
| 19 |
+
- raise ValueError('Data is not serializable.')
|
| 20 |
+
+ # Serialize the database state using the user-provided arguments
|
| 21 |
+
+ serialized = json.dumps(data, **self.kwargs)
|
| 22 |
+
|
| 23 |
+
+ # Write the serialized data to the file
|
| 24 |
+
try:
|
| 25 |
+
self._handle.write(serialized)
|
| 26 |
+
except io.UnsupportedOperation:
|
| 27 |
+
raise IOError('Cannot write to the database. Access mode is "{0}"'.format(self._mode))
|
| 28 |
+
|
| 29 |
+
+ # Ensure the file has been written
|
| 30 |
+
self._handle.flush()
|
| 31 |
+
os.fsync(self._handle.fileno())
|
| 32 |
+
|
| 33 |
+
- new_offset = len(serialized)
|
| 34 |
+
- self._handle.seek(new_offset)
|
| 35 |
+
+ # Remove data that is behind the new cursor in case the file has
|
| 36 |
+
+ # gotten shorter
|
| 37 |
+
self._handle.truncate()
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
OPENENV_REFERENCE
|
| 41 |
+
/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/task.toml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[agent]
|
| 4 |
+
timeout_sec = 1800.0
|
| 5 |
+
|
| 6 |
+
[verifier]
|
| 7 |
+
timeout_sec = 900.0
|
| 8 |
+
|
| 9 |
+
[environment]
|
| 10 |
+
docker_image = "ghcr.io/younesbelkada/scale800@sha256:bce59ccb3d987af46af3296291a49c81579fda562019c08fec0f809446291012"
|
| 11 |
+
build_timeout_sec = 600.0
|
| 12 |
+
cpus = 2
|
| 13 |
+
memory_mb = 8192
|
| 14 |
+
storage_mb = 16384
|
| 15 |
+
|
| 16 |
+
[metadata]
|
| 17 |
+
author_name = "SWE-smith source adapter"
|
| 18 |
+
category = "bugfix"
|
| 19 |
+
tags = ["swe", "python", "mutation-repair"]
|
| 20 |
+
|
| 21 |
+
[environment.env]
|
| 22 |
+
# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's
|
| 23 |
+
# non-interactive shells never run `conda activate`
|
| 24 |
+
PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/check_pytest.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Preserve confirmed requested assertion failures; keep positive checks strict."""
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import xml.etree.ElementTree as ET
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
GROUPS = ("pass-to-pass", "fail-to-pass")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def split_nodeid(target):
|
| 14 |
+
prefix, bracket, parameter = target.partition("[")
|
| 15 |
+
parts = prefix.split("::")
|
| 16 |
+
if bracket:
|
| 17 |
+
parts[-1] += bracket + parameter
|
| 18 |
+
return parts
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def matches(case, target):
|
| 22 |
+
parts = split_nodeid(target)
|
| 23 |
+
module = parts[0].removesuffix(".py").replace("/", ".")
|
| 24 |
+
classname, name = case.get("classname", ""), case.get("name", "")
|
| 25 |
+
if not (classname == module or classname.startswith(module + ".")):
|
| 26 |
+
return False
|
| 27 |
+
selector = parts[-1] if len(parts) > 1 else ""
|
| 28 |
+
classes = parts[1:-1]
|
| 29 |
+
if classes and classname != module + "." + ".".join(classes):
|
| 30 |
+
return False
|
| 31 |
+
return (
|
| 32 |
+
not selector
|
| 33 |
+
or name == selector
|
| 34 |
+
or ("[" not in selector and name.startswith(selector + "["))
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def capture_panels(root):
|
| 39 |
+
panels, digests = {}, {}
|
| 40 |
+
for group in GROUPS:
|
| 41 |
+
path = Path(root) / (group + ".xml")
|
| 42 |
+
if not path.exists():
|
| 43 |
+
panels[group] = None
|
| 44 |
+
continue
|
| 45 |
+
with path.open("rb") as stream:
|
| 46 |
+
raw = stream.read(4 * 1024**2 + 1)
|
| 47 |
+
if not 0 < len(raw) <= 4 * 1024**2 or re.search(
|
| 48 |
+
rb"<!\s*(?:DOCTYPE|ENTITY)", raw, re.I
|
| 49 |
+
):
|
| 50 |
+
raise ValueError("Unbounded or unsafe pytest XML")
|
| 51 |
+
try:
|
| 52 |
+
tree = ET.fromstring(raw)
|
| 53 |
+
except ET.ParseError:
|
| 54 |
+
raise ValueError("Malformed pytest XML") from None
|
| 55 |
+
cases = list(tree.iter("testcase"))
|
| 56 |
+
if len(cases) > 20000:
|
| 57 |
+
raise ValueError("Too many pytest cases")
|
| 58 |
+
identities = [(case.get("classname"), case.get("name")) for case in cases]
|
| 59 |
+
if len(identities) != len(set(identities)):
|
| 60 |
+
raise ValueError("Duplicate pytest case evidence")
|
| 61 |
+
panels[group] = cases
|
| 62 |
+
digests[group] = hashlib.sha256(raw).hexdigest()
|
| 63 |
+
return panels, digests
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def strict_assess(panels, expected, native_exit):
|
| 67 |
+
"""The original positive-approval conditions, applied to captured cases."""
|
| 68 |
+
all_cases, actual_failure = [], False
|
| 69 |
+
for group in GROUPS:
|
| 70 |
+
cases = panels[group]
|
| 71 |
+
if cases is None:
|
| 72 |
+
if actual_failure:
|
| 73 |
+
continue
|
| 74 |
+
raise ValueError("Missing preceding pytest panel")
|
| 75 |
+
if actual_failure:
|
| 76 |
+
raise ValueError(
|
| 77 |
+
"Pytest evidence continued after the native stop-on-failure"
|
| 78 |
+
)
|
| 79 |
+
targets = expected[group]
|
| 80 |
+
if any(not any(matches(case, target) for target in targets) for case in cases):
|
| 81 |
+
raise ValueError("Unexpected pytest case")
|
| 82 |
+
all_cases.extend(cases)
|
| 83 |
+
failures = [case for case in cases if case.find("failure") is not None]
|
| 84 |
+
if any(
|
| 85 |
+
case.find("error") is not None or case.find("skipped") is not None
|
| 86 |
+
for case in cases
|
| 87 |
+
):
|
| 88 |
+
raise ValueError("Pytest collection/error/skip is not a completed panel")
|
| 89 |
+
actual_failure = actual_failure or bool(failures)
|
| 90 |
+
if not failures and any(
|
| 91 |
+
not any(matches(case, target) for case in cases) for target in targets
|
| 92 |
+
):
|
| 93 |
+
raise ValueError("Declared pytest target never ran")
|
| 94 |
+
if actual_failure:
|
| 95 |
+
if native_exit == 0:
|
| 96 |
+
raise ValueError("Native verifier exit disagrees with pytest failure")
|
| 97 |
+
return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)}
|
| 98 |
+
if native_exit != 0:
|
| 99 |
+
raise ValueError("Setup or native verifier failed without a real test failure")
|
| 100 |
+
if any(panels[group] is None for group in GROUPS):
|
| 101 |
+
raise ValueError("Missing completed pytest panel")
|
| 102 |
+
return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def assess(root, expected, native_exit):
|
| 106 |
+
if type(native_exit) is not int:
|
| 107 |
+
raise ValueError("Native verifier exit must be an integer")
|
| 108 |
+
if not isinstance(expected, dict) or any(
|
| 109 |
+
not isinstance(expected.get(group), list)
|
| 110 |
+
or not expected[group]
|
| 111 |
+
or any(not isinstance(target, str) or not target for target in expected[group])
|
| 112 |
+
for group in GROUPS
|
| 113 |
+
):
|
| 114 |
+
raise ValueError("Complete exact native pytest targets required")
|
| 115 |
+
panels, digests = capture_panels(root)
|
| 116 |
+
counts = {
|
| 117 |
+
"cases": 0,
|
| 118 |
+
"matched_failures": 0,
|
| 119 |
+
"unexpected_cases": 0,
|
| 120 |
+
"unmatched_failures": 0,
|
| 121 |
+
"skipped_cases": 0,
|
| 122 |
+
"error_cases": 0,
|
| 123 |
+
"missing_panels": 0,
|
| 124 |
+
"missing_targets": 0,
|
| 125 |
+
}
|
| 126 |
+
for group in GROUPS:
|
| 127 |
+
cases = panels[group]
|
| 128 |
+
if cases is None:
|
| 129 |
+
counts["missing_panels"] += 1
|
| 130 |
+
counts["missing_targets"] += len(expected[group])
|
| 131 |
+
continue
|
| 132 |
+
counts["cases"] += len(cases)
|
| 133 |
+
for case in cases:
|
| 134 |
+
requested = any(matches(case, target) for target in expected[group])
|
| 135 |
+
failure = case.find("failure") is not None
|
| 136 |
+
counts["matched_failures"] += int(requested and failure)
|
| 137 |
+
counts["unmatched_failures"] += int(not requested and failure)
|
| 138 |
+
counts["unexpected_cases"] += int(not requested)
|
| 139 |
+
counts["skipped_cases"] += int(case.find("skipped") is not None)
|
| 140 |
+
counts["error_cases"] += int(case.find("error") is not None)
|
| 141 |
+
counts["missing_targets"] += sum(
|
| 142 |
+
not any(matches(case, target) for case in cases)
|
| 143 |
+
for target in expected[group]
|
| 144 |
+
)
|
| 145 |
+
if counts["matched_failures"]:
|
| 146 |
+
if native_exit == 0:
|
| 147 |
+
raise ValueError(
|
| 148 |
+
"Native verifier exit disagrees with requested pytest failure"
|
| 149 |
+
)
|
| 150 |
+
return {
|
| 151 |
+
"reward": 0,
|
| 152 |
+
"valid_test_failure": True,
|
| 153 |
+
"cases": counts["cases"],
|
| 154 |
+
"diagnostic_counts": counts,
|
| 155 |
+
"panel_sha256": digests,
|
| 156 |
+
"decision": "confirmed_requested_failure_precedence",
|
| 157 |
+
}
|
| 158 |
+
result = strict_assess(panels, expected, native_exit)
|
| 159 |
+
result.update(diagnostic_counts=counts, panel_sha256=digests)
|
| 160 |
+
return result
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
if __name__ == "__main__":
|
| 164 |
+
parser = argparse.ArgumentParser()
|
| 165 |
+
parser.add_argument("--root", required=True)
|
| 166 |
+
parser.add_argument("--expected", required=True)
|
| 167 |
+
parser.add_argument("--native-exit", type=int, required=True)
|
| 168 |
+
args = parser.parse_args()
|
| 169 |
+
result = assess(
|
| 170 |
+
args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit
|
| 171 |
+
)
|
| 172 |
+
reward = Path(args.root) / "reward.txt"
|
| 173 |
+
if reward.read_text().strip() != str(result["reward"]):
|
| 174 |
+
raise ValueError("Native raw reward disagrees with pytest evidence")
|
| 175 |
+
(Path(args.root) / "pytest-evidence.json").write_text(
|
| 176 |
+
json.dumps(result, sort_keys=True) + "\n"
|
| 177 |
+
)
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/expected-panels.json
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fail-to-pass": [
|
| 3 |
+
"tests/test_storages.py::test_json_kwargs",
|
| 4 |
+
"tests/test_tinydb.py::test_insert_invalid_dict"
|
| 5 |
+
],
|
| 6 |
+
"pass-to-pass": [
|
| 7 |
+
"tests/test_middlewares.py::test_caching",
|
| 8 |
+
"tests/test_middlewares.py::test_caching_read",
|
| 9 |
+
"tests/test_middlewares.py::test_caching_write_many",
|
| 10 |
+
"tests/test_middlewares.py::test_caching_flush",
|
| 11 |
+
"tests/test_middlewares.py::test_caching_flush_manually",
|
| 12 |
+
"tests/test_middlewares.py::test_caching_write",
|
| 13 |
+
"tests/test_middlewares.py::test_nested",
|
| 14 |
+
"tests/test_middlewares.py::test_caching_json_write",
|
| 15 |
+
"tests/test_operations.py::test_delete[memory]",
|
| 16 |
+
"tests/test_operations.py::test_delete[json]",
|
| 17 |
+
"tests/test_operations.py::test_add_int[memory]",
|
| 18 |
+
"tests/test_operations.py::test_add_int[json]",
|
| 19 |
+
"tests/test_operations.py::test_add_str[memory]",
|
| 20 |
+
"tests/test_operations.py::test_add_str[json]",
|
| 21 |
+
"tests/test_operations.py::test_subtract[memory]",
|
| 22 |
+
"tests/test_operations.py::test_subtract[json]",
|
| 23 |
+
"tests/test_operations.py::test_set[memory]",
|
| 24 |
+
"tests/test_operations.py::test_set[json]",
|
| 25 |
+
"tests/test_operations.py::test_increment[memory]",
|
| 26 |
+
"tests/test_operations.py::test_increment[json]",
|
| 27 |
+
"tests/test_operations.py::test_decrement[memory]",
|
| 28 |
+
"tests/test_operations.py::test_decrement[json]",
|
| 29 |
+
"tests/test_queries.py::test_no_path",
|
| 30 |
+
"tests/test_queries.py::test_path_exists",
|
| 31 |
+
"tests/test_queries.py::test_path_and",
|
| 32 |
+
"tests/test_queries.py::test_callable_in_path_with_map",
|
| 33 |
+
"tests/test_queries.py::test_callable_in_path_with_chain",
|
| 34 |
+
"tests/test_queries.py::test_eq",
|
| 35 |
+
"tests/test_queries.py::test_ne",
|
| 36 |
+
"tests/test_queries.py::test_lt",
|
| 37 |
+
"tests/test_queries.py::test_le",
|
| 38 |
+
"tests/test_queries.py::test_gt",
|
| 39 |
+
"tests/test_queries.py::test_ge",
|
| 40 |
+
"tests/test_queries.py::test_or",
|
| 41 |
+
"tests/test_queries.py::test_and",
|
| 42 |
+
"tests/test_queries.py::test_not",
|
| 43 |
+
"tests/test_queries.py::test_has_key",
|
| 44 |
+
"tests/test_queries.py::test_regex",
|
| 45 |
+
"tests/test_queries.py::test_custom",
|
| 46 |
+
"tests/test_queries.py::test_custom_with_params",
|
| 47 |
+
"tests/test_queries.py::test_any",
|
| 48 |
+
"tests/test_queries.py::test_all",
|
| 49 |
+
"tests/test_queries.py::test_has",
|
| 50 |
+
"tests/test_queries.py::test_one_of",
|
| 51 |
+
"tests/test_queries.py::test_hash",
|
| 52 |
+
"tests/test_queries.py::test_orm_usage",
|
| 53 |
+
"tests/test_queries.py::test_repr",
|
| 54 |
+
"tests/test_queries.py::test_subclass",
|
| 55 |
+
"tests/test_queries.py::test_noop",
|
| 56 |
+
"tests/test_queries.py::test_equality",
|
| 57 |
+
"tests/test_queries.py::test_empty_query_error",
|
| 58 |
+
"tests/test_queries.py::test_fragment",
|
| 59 |
+
"tests/test_queries.py::test_fragment_with_path",
|
| 60 |
+
"tests/test_queries.py::test_get_item",
|
| 61 |
+
"tests/test_storages.py::test_json",
|
| 62 |
+
"tests/test_storages.py::test_json_readwrite",
|
| 63 |
+
"tests/test_storages.py::test_json_read",
|
| 64 |
+
"tests/test_storages.py::test_create_dirs",
|
| 65 |
+
"tests/test_storages.py::test_json_invalid_directory",
|
| 66 |
+
"tests/test_storages.py::test_in_memory",
|
| 67 |
+
"tests/test_storages.py::test_in_memory_close",
|
| 68 |
+
"tests/test_storages.py::test_custom",
|
| 69 |
+
"tests/test_storages.py::test_read_once",
|
| 70 |
+
"tests/test_storages.py::test_custom_with_exception",
|
| 71 |
+
"tests/test_storages.py::test_yaml",
|
| 72 |
+
"tests/test_storages.py::test_encoding",
|
| 73 |
+
"tests/test_tables.py::test_next_id[memory]",
|
| 74 |
+
"tests/test_tables.py::test_next_id[json]",
|
| 75 |
+
"tests/test_tables.py::test_tables_list[memory]",
|
| 76 |
+
"tests/test_tables.py::test_tables_list[json]",
|
| 77 |
+
"tests/test_tables.py::test_one_table[memory]",
|
| 78 |
+
"tests/test_tables.py::test_one_table[json]",
|
| 79 |
+
"tests/test_tables.py::test_multiple_tables[memory]",
|
| 80 |
+
"tests/test_tables.py::test_multiple_tables[json]",
|
| 81 |
+
"tests/test_tables.py::test_caching[memory]",
|
| 82 |
+
"tests/test_tables.py::test_caching[json]",
|
| 83 |
+
"tests/test_tables.py::test_query_cache[memory]",
|
| 84 |
+
"tests/test_tables.py::test_query_cache[json]",
|
| 85 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[memory]",
|
| 86 |
+
"tests/test_tables.py::test_query_cache_with_mutable_callable[json]",
|
| 87 |
+
"tests/test_tables.py::test_zero_cache_size[memory]",
|
| 88 |
+
"tests/test_tables.py::test_zero_cache_size[json]",
|
| 89 |
+
"tests/test_tables.py::test_query_cache_size[memory]",
|
| 90 |
+
"tests/test_tables.py::test_query_cache_size[json]",
|
| 91 |
+
"tests/test_tables.py::test_lru_cache[memory]",
|
| 92 |
+
"tests/test_tables.py::test_lru_cache[json]",
|
| 93 |
+
"tests/test_tables.py::test_table_is_iterable[memory]",
|
| 94 |
+
"tests/test_tables.py::test_table_is_iterable[json]",
|
| 95 |
+
"tests/test_tables.py::test_table_name[memory]",
|
| 96 |
+
"tests/test_tables.py::test_table_name[json]",
|
| 97 |
+
"tests/test_tables.py::test_table_repr[memory]",
|
| 98 |
+
"tests/test_tables.py::test_table_repr[json]",
|
| 99 |
+
"tests/test_tables.py::test_truncate_table[memory]",
|
| 100 |
+
"tests/test_tables.py::test_truncate_table[json]",
|
| 101 |
+
"tests/test_tables.py::test_persist_table[memory]",
|
| 102 |
+
"tests/test_tables.py::test_persist_table[json]",
|
| 103 |
+
"tests/test_tinydb.py::test_drop_tables[memory]",
|
| 104 |
+
"tests/test_tinydb.py::test_drop_tables[json]",
|
| 105 |
+
"tests/test_tinydb.py::test_all[memory]",
|
| 106 |
+
"tests/test_tinydb.py::test_all[json]",
|
| 107 |
+
"tests/test_tinydb.py::test_insert[memory]",
|
| 108 |
+
"tests/test_tinydb.py::test_insert[json]",
|
| 109 |
+
"tests/test_tinydb.py::test_insert_ids[memory]",
|
| 110 |
+
"tests/test_tinydb.py::test_insert_ids[json]",
|
| 111 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[memory]",
|
| 112 |
+
"tests/test_tinydb.py::test_insert_with_doc_id[json]",
|
| 113 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[memory]",
|
| 114 |
+
"tests/test_tinydb.py::test_insert_with_duplicate_doc_id[json]",
|
| 115 |
+
"tests/test_tinydb.py::test_insert_multiple[memory]",
|
| 116 |
+
"tests/test_tinydb.py::test_insert_multiple[json]",
|
| 117 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[memory]",
|
| 118 |
+
"tests/test_tinydb.py::test_insert_multiple_with_ids[json]",
|
| 119 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[memory]",
|
| 120 |
+
"tests/test_tinydb.py::test_insert_multiple_with_doc_ids[json]",
|
| 121 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[memory]",
|
| 122 |
+
"tests/test_tinydb.py::test_insert_invalid_type_raises_error[json]",
|
| 123 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[memory]",
|
| 124 |
+
"tests/test_tinydb.py::test_insert_valid_mapping_type[json]",
|
| 125 |
+
"tests/test_tinydb.py::test_custom_mapping_type_with_json",
|
| 126 |
+
"tests/test_tinydb.py::test_remove[memory]",
|
| 127 |
+
"tests/test_tinydb.py::test_remove[json]",
|
| 128 |
+
"tests/test_tinydb.py::test_remove_all_fails[memory]",
|
| 129 |
+
"tests/test_tinydb.py::test_remove_all_fails[json]",
|
| 130 |
+
"tests/test_tinydb.py::test_remove_multiple[memory]",
|
| 131 |
+
"tests/test_tinydb.py::test_remove_multiple[json]",
|
| 132 |
+
"tests/test_tinydb.py::test_remove_ids[memory]",
|
| 133 |
+
"tests/test_tinydb.py::test_remove_ids[json]",
|
| 134 |
+
"tests/test_tinydb.py::test_remove_returns_ids[memory]",
|
| 135 |
+
"tests/test_tinydb.py::test_remove_returns_ids[json]",
|
| 136 |
+
"tests/test_tinydb.py::test_update[memory]",
|
| 137 |
+
"tests/test_tinydb.py::test_update[json]",
|
| 138 |
+
"tests/test_tinydb.py::test_update_all[memory]",
|
| 139 |
+
"tests/test_tinydb.py::test_update_all[json]",
|
| 140 |
+
"tests/test_tinydb.py::test_update_returns_ids[memory]",
|
| 141 |
+
"tests/test_tinydb.py::test_update_returns_ids[json]",
|
| 142 |
+
"tests/test_tinydb.py::test_update_transform[memory]",
|
| 143 |
+
"tests/test_tinydb.py::test_update_transform[json]",
|
| 144 |
+
"tests/test_tinydb.py::test_update_ids[memory]",
|
| 145 |
+
"tests/test_tinydb.py::test_update_ids[json]",
|
| 146 |
+
"tests/test_tinydb.py::test_update_multiple[memory]",
|
| 147 |
+
"tests/test_tinydb.py::test_update_multiple[json]",
|
| 148 |
+
"tests/test_tinydb.py::test_update_multiple_operation[memory]",
|
| 149 |
+
"tests/test_tinydb.py::test_update_multiple_operation[json]",
|
| 150 |
+
"tests/test_tinydb.py::test_upsert[memory]",
|
| 151 |
+
"tests/test_tinydb.py::test_upsert[json]",
|
| 152 |
+
"tests/test_tinydb.py::test_upsert_by_id[memory]",
|
| 153 |
+
"tests/test_tinydb.py::test_upsert_by_id[json]",
|
| 154 |
+
"tests/test_tinydb.py::test_search[memory]",
|
| 155 |
+
"tests/test_tinydb.py::test_search[json]",
|
| 156 |
+
"tests/test_tinydb.py::test_search_path[memory]",
|
| 157 |
+
"tests/test_tinydb.py::test_search_path[json]",
|
| 158 |
+
"tests/test_tinydb.py::test_search_no_results_cache[memory]",
|
| 159 |
+
"tests/test_tinydb.py::test_search_no_results_cache[json]",
|
| 160 |
+
"tests/test_tinydb.py::test_get[memory]",
|
| 161 |
+
"tests/test_tinydb.py::test_get[json]",
|
| 162 |
+
"tests/test_tinydb.py::test_get_ids[memory]",
|
| 163 |
+
"tests/test_tinydb.py::test_get_ids[json]",
|
| 164 |
+
"tests/test_tinydb.py::test_get_multiple_ids[memory]",
|
| 165 |
+
"tests/test_tinydb.py::test_get_multiple_ids[json]",
|
| 166 |
+
"tests/test_tinydb.py::test_get_invalid[memory]",
|
| 167 |
+
"tests/test_tinydb.py::test_get_invalid[json]",
|
| 168 |
+
"tests/test_tinydb.py::test_count[memory]",
|
| 169 |
+
"tests/test_tinydb.py::test_count[json]",
|
| 170 |
+
"tests/test_tinydb.py::test_contains[memory]",
|
| 171 |
+
"tests/test_tinydb.py::test_contains[json]",
|
| 172 |
+
"tests/test_tinydb.py::test_contains_ids[memory]",
|
| 173 |
+
"tests/test_tinydb.py::test_contains_ids[json]",
|
| 174 |
+
"tests/test_tinydb.py::test_contains_invalid[memory]",
|
| 175 |
+
"tests/test_tinydb.py::test_contains_invalid[json]",
|
| 176 |
+
"tests/test_tinydb.py::test_get_idempotent[memory]",
|
| 177 |
+
"tests/test_tinydb.py::test_get_idempotent[json]",
|
| 178 |
+
"tests/test_tinydb.py::test_multiple_dbs",
|
| 179 |
+
"tests/test_tinydb.py::test_storage_closed_once",
|
| 180 |
+
"tests/test_tinydb.py::test_unique_ids",
|
| 181 |
+
"tests/test_tinydb.py::test_lastid_after_open",
|
| 182 |
+
"tests/test_tinydb.py::test_doc_ids_json",
|
| 183 |
+
"tests/test_tinydb.py::test_insert_string",
|
| 184 |
+
"tests/test_tinydb.py::test_gc",
|
| 185 |
+
"tests/test_tinydb.py::test_drop_table",
|
| 186 |
+
"tests/test_tinydb.py::test_empty_write",
|
| 187 |
+
"tests/test_tinydb.py::test_query_cache",
|
| 188 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[memory]",
|
| 189 |
+
"tests/test_tinydb.py::test_tinydb_is_iterable[json]",
|
| 190 |
+
"tests/test_tinydb.py::test_repr",
|
| 191 |
+
"tests/test_tinydb.py::test_delete",
|
| 192 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[memory]",
|
| 193 |
+
"tests/test_tinydb.py::test_insert_multiple_with_single_dict[json]",
|
| 194 |
+
"tests/test_tinydb.py::test_access_storage",
|
| 195 |
+
"tests/test_tinydb.py::test_empty_db_len",
|
| 196 |
+
"tests/test_tinydb.py::test_insert_on_existing_db",
|
| 197 |
+
"tests/test_tinydb.py::test_storage_access",
|
| 198 |
+
"tests/test_tinydb.py::test_lambda_query",
|
| 199 |
+
"tests/test_utils.py::test_lru_cache",
|
| 200 |
+
"tests/test_utils.py::test_lru_cache_set_multiple",
|
| 201 |
+
"tests/test_utils.py::test_lru_cache_set_update",
|
| 202 |
+
"tests/test_utils.py::test_lru_cache_get",
|
| 203 |
+
"tests/test_utils.py::test_lru_cache_delete",
|
| 204 |
+
"tests/test_utils.py::test_lru_cache_clear",
|
| 205 |
+
"tests/test_utils.py::test_lru_cache_unlimited",
|
| 206 |
+
"tests/test_utils.py::test_lru_cache_unlimited_explicit",
|
| 207 |
+
"tests/test_utils.py::test_lru_cache_iteration_works",
|
| 208 |
+
"tests/test_utils.py::test_freeze"
|
| 209 |
+
]
|
| 210 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/grade.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Trusted private pytest panel runner. Installed only in a fresh grader Job."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import importlib.util
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import shutil
|
| 8 |
+
import stat
|
| 9 |
+
import subprocess
|
| 10 |
+
from pathlib import Path, PurePosixPath
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def sha(raw):
|
| 14 |
+
return hashlib.sha256(raw).hexdigest()
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def safe(value):
|
| 18 |
+
path = PurePosixPath(value)
|
| 19 |
+
if (
|
| 20 |
+
path.is_absolute()
|
| 21 |
+
or path.as_posix() != value
|
| 22 |
+
or not path.parts
|
| 23 |
+
or any(part in {".", "..", ".git"} for part in path.parts)
|
| 24 |
+
):
|
| 25 |
+
raise ValueError("Unsafe trusted test path")
|
| 26 |
+
return path
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def restore(worktree, private, manifest):
|
| 30 |
+
worktree, private = Path(worktree), Path(private)
|
| 31 |
+
captured = {}
|
| 32 |
+
for name, expected in manifest["files"].items():
|
| 33 |
+
path = private / safe(name)
|
| 34 |
+
info = path.lstat()
|
| 35 |
+
raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b""
|
| 36 |
+
if (
|
| 37 |
+
not stat.S_ISREG(info.st_mode)
|
| 38 |
+
or len(raw) != expected["bytes"]
|
| 39 |
+
or sha(raw) != expected["sha256"]
|
| 40 |
+
or stat.S_IMODE(info.st_mode) != expected["mode"]
|
| 41 |
+
):
|
| 42 |
+
raise ValueError("Trusted private test bytes or modes drifted")
|
| 43 |
+
captured[name] = (raw, expected["mode"])
|
| 44 |
+
# Capture and verify every private byte before changing the submitted tree.
|
| 45 |
+
for name in manifest["directory_roots"]:
|
| 46 |
+
destination = worktree / safe(name)
|
| 47 |
+
if destination.is_symlink():
|
| 48 |
+
raise ValueError("Submitted test directory is a symlink")
|
| 49 |
+
for parent in destination.parents:
|
| 50 |
+
if parent == worktree:
|
| 51 |
+
break
|
| 52 |
+
if parent.is_symlink():
|
| 53 |
+
raise ValueError("Submitted test parent is a symlink")
|
| 54 |
+
if destination.exists():
|
| 55 |
+
if not destination.is_dir():
|
| 56 |
+
raise ValueError("Submitted test directory is not a directory")
|
| 57 |
+
shutil.rmtree(destination)
|
| 58 |
+
for name, (raw, mode) in captured.items():
|
| 59 |
+
destination = worktree / safe(name)
|
| 60 |
+
for parent in destination.parents:
|
| 61 |
+
if parent == worktree:
|
| 62 |
+
break
|
| 63 |
+
if parent.is_symlink():
|
| 64 |
+
raise ValueError("Submitted test parent is a symlink")
|
| 65 |
+
if destination.is_symlink():
|
| 66 |
+
raise ValueError("Submitted trusted file is a symlink")
|
| 67 |
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
| 68 |
+
destination.write_bytes(raw)
|
| 69 |
+
destination.chmod(mode)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def run(worktree, private_root, output, invoke=None):
|
| 73 |
+
private_root, output, worktree = Path(private_root), Path(output), Path(worktree)
|
| 74 |
+
expected = json.loads((private_root / "expected-panels.json").read_bytes())
|
| 75 |
+
config = json.loads((private_root / "panel-config.json").read_bytes())
|
| 76 |
+
manifest = json.loads((private_root / "trusted-inventory.json").read_bytes())
|
| 77 |
+
restore(worktree, private_root / "trusted", manifest)
|
| 78 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 79 |
+
for name in (
|
| 80 |
+
"reward.txt",
|
| 81 |
+
"pass-to-pass.xml",
|
| 82 |
+
"fail-to-pass.xml",
|
| 83 |
+
"pytest-evidence.json",
|
| 84 |
+
):
|
| 85 |
+
(output / name).unlink(missing_ok=True)
|
| 86 |
+
environment = dict(os.environ)
|
| 87 |
+
for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"):
|
| 88 |
+
environment.pop(key, None)
|
| 89 |
+
commands, native_exit = [], 0
|
| 90 |
+
invoke = invoke or subprocess.run
|
| 91 |
+
for group in ("pass-to-pass", "fail-to-pass"):
|
| 92 |
+
if (
|
| 93 |
+
not isinstance(expected[group], list)
|
| 94 |
+
or not expected[group]
|
| 95 |
+
or any(
|
| 96 |
+
not isinstance(target, str) or not target for target in expected[group]
|
| 97 |
+
)
|
| 98 |
+
):
|
| 99 |
+
raise ValueError("Frozen native pytest selectors are incomplete")
|
| 100 |
+
command = [
|
| 101 |
+
*config["official_pytest_argv"],
|
| 102 |
+
"--override-ini=addopts=",
|
| 103 |
+
"--junitxml=" + str(output / (group + ".xml")),
|
| 104 |
+
*expected[group],
|
| 105 |
+
]
|
| 106 |
+
result = invoke(command, cwd=worktree, env=environment, check=False)
|
| 107 |
+
native_exit = result.returncode
|
| 108 |
+
commands.append({"group": group, "argv": command, "exit_code": native_exit})
|
| 109 |
+
if native_exit != 0:
|
| 110 |
+
break
|
| 111 |
+
(output / "pytest-commands.json").write_text(
|
| 112 |
+
json.dumps(commands, sort_keys=True) + "\n"
|
| 113 |
+
)
|
| 114 |
+
spec = importlib.util.spec_from_file_location(
|
| 115 |
+
"trusted_pytest_result", private_root / "check_pytest.py"
|
| 116 |
+
)
|
| 117 |
+
checker = importlib.util.module_from_spec(spec)
|
| 118 |
+
spec.loader.exec_module(checker)
|
| 119 |
+
result = checker.assess(output, expected, native_exit)
|
| 120 |
+
(output / "reward.txt").write_text(str(result["reward"]) + "\n")
|
| 121 |
+
(output / "pytest-evidence.json").write_text(
|
| 122 |
+
json.dumps(result, sort_keys=True) + "\n"
|
| 123 |
+
)
|
| 124 |
+
return result
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
if __name__ == "__main__":
|
| 128 |
+
run("/testbed/repo", "/tests", "/logs/verifier")
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/panel-config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dependency_installation_pinned": false,
|
| 3 |
+
"official_install_cmds": [
|
| 4 |
+
"python -m pip install -e ."
|
| 5 |
+
],
|
| 6 |
+
"official_pytest_argv": [
|
| 7 |
+
"pytest",
|
| 8 |
+
"--disable-warnings",
|
| 9 |
+
"--color=no",
|
| 10 |
+
"--tb=no",
|
| 11 |
+
"--verbose"
|
| 12 |
+
],
|
| 13 |
+
"official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose",
|
| 14 |
+
"panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.",
|
| 15 |
+
"python_version": "3.10",
|
| 16 |
+
"source_bound_test_dependency_cmds": [
|
| 17 |
+
"python -m pip install 'pytest>=7.2,<8' 'pytest-cov>=4,<5'"
|
| 18 |
+
],
|
| 19 |
+
"test_dependency_source_sha256": {
|
| 20 |
+
"pyproject.toml": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be",
|
| 21 |
+
"pytest.ini": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 22 |
+
}
|
| 23 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/test.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -Eeuo pipefail
|
| 3 |
+
source /opt/miniconda3/bin/activate
|
| 4 |
+
conda activate testbed
|
| 5 |
+
cd /testbed/repo
|
| 6 |
+
exec python -I /tests/grade.py
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted-inventory.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"directory_roots": [
|
| 3 |
+
"tests"
|
| 4 |
+
],
|
| 5 |
+
"files": {
|
| 6 |
+
"pyproject.toml": {
|
| 7 |
+
"bytes": 1846,
|
| 8 |
+
"mode": 420,
|
| 9 |
+
"sha256": "4318e4525086b9ab07b2269c7a6f1ff2003ad01a663b94f56e772d63655166be"
|
| 10 |
+
},
|
| 11 |
+
"pytest.ini": {
|
| 12 |
+
"bytes": 70,
|
| 13 |
+
"mode": 420,
|
| 14 |
+
"sha256": "2c2ccbf97dabef288fd402c4bb1ddba4d3baa35d1f903a3f5735633c1d504b7c"
|
| 15 |
+
},
|
| 16 |
+
"tests/__init__.py": {
|
| 17 |
+
"bytes": 0,
|
| 18 |
+
"mode": 420,
|
| 19 |
+
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
| 20 |
+
},
|
| 21 |
+
"tests/conftest.py": {
|
| 22 |
+
"bytes": 625,
|
| 23 |
+
"mode": 420,
|
| 24 |
+
"sha256": "502596fae1843322ec533028a76474d39e6fb70587a5749d8c9dd734b35e625b"
|
| 25 |
+
},
|
| 26 |
+
"tests/test_middlewares.py": {
|
| 27 |
+
"bytes": 2412,
|
| 28 |
+
"mode": 420,
|
| 29 |
+
"sha256": "85a748d3d10e7be042ed37318153a6b79c7913a5d9536cad406ccccad380577b"
|
| 30 |
+
},
|
| 31 |
+
"tests/test_operations.py": {
|
| 32 |
+
"bytes": 1021,
|
| 33 |
+
"mode": 420,
|
| 34 |
+
"sha256": "6313d342626a12973a5532b0b9344c5a30a959d7bfa4f6ca07d147317aee469e"
|
| 35 |
+
},
|
| 36 |
+
"tests/test_queries.py": {
|
| 37 |
+
"bytes": 12331,
|
| 38 |
+
"mode": 420,
|
| 39 |
+
"sha256": "7978c6220a192f4256018bf37d76e6b4c644a962fed4d6fca7d8594b2cf63a49"
|
| 40 |
+
},
|
| 41 |
+
"tests/test_storages.py": {
|
| 42 |
+
"bytes": 6489,
|
| 43 |
+
"mode": 420,
|
| 44 |
+
"sha256": "d74695d20e1d1742fa558da49bc2df8e84ca34e64e001070cbccce215bd39fa2"
|
| 45 |
+
},
|
| 46 |
+
"tests/test_tables.py": {
|
| 47 |
+
"bytes": 4109,
|
| 48 |
+
"mode": 420,
|
| 49 |
+
"sha256": "f018615899e7c9c813aba0820c639f9402d3c9865a376eedaf9dc3ee89b85ef3"
|
| 50 |
+
},
|
| 51 |
+
"tests/test_tinydb.py": {
|
| 52 |
+
"bytes": 18110,
|
| 53 |
+
"mode": 420,
|
| 54 |
+
"sha256": "d106d5e94536afe8416c1b8b01bc63381abb97f81a6a120743e7e1963b07b1d1"
|
| 55 |
+
},
|
| 56 |
+
"tests/test_utils.py": {
|
| 57 |
+
"bytes": 2257,
|
| 58 |
+
"mode": 420,
|
| 59 |
+
"sha256": "659bd414226988e81d2811259c112676aa6bdfa3b9fb6fed4631030ae6d73f2e"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted/pyproject.toml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.poetry]
|
| 2 |
+
name = "tinydb"
|
| 3 |
+
version = "4.8.2"
|
| 4 |
+
description = "TinyDB is a tiny, document oriented database optimized for your happiness :)"
|
| 5 |
+
authors = ["Markus Siemens <markus@m-siemens.de>"]
|
| 6 |
+
license = "MIT"
|
| 7 |
+
|
| 8 |
+
readme = "README.rst"
|
| 9 |
+
|
| 10 |
+
homepage = "https://github.com/msiemens/tinydb"
|
| 11 |
+
documentation = "https://tinydb.readthedocs.org/"
|
| 12 |
+
|
| 13 |
+
keywords = ["database", "nosql"]
|
| 14 |
+
|
| 15 |
+
classifiers = [
|
| 16 |
+
"Development Status :: 5 - Production/Stable",
|
| 17 |
+
"Intended Audience :: Developers",
|
| 18 |
+
"Intended Audience :: System Administrators",
|
| 19 |
+
"License :: OSI Approved :: MIT License",
|
| 20 |
+
"Topic :: Database",
|
| 21 |
+
"Topic :: Database :: Database Engines/Servers",
|
| 22 |
+
"Topic :: Utilities",
|
| 23 |
+
"Programming Language :: Python :: 3",
|
| 24 |
+
"Programming Language :: Python :: 3.8",
|
| 25 |
+
"Programming Language :: Python :: 3.9",
|
| 26 |
+
"Programming Language :: Python :: 3.10",
|
| 27 |
+
"Programming Language :: Python :: 3.11",
|
| 28 |
+
"Programming Language :: Python :: 3.12",
|
| 29 |
+
"Programming Language :: Python :: 3.13",
|
| 30 |
+
"Programming Language :: Python :: Implementation :: CPython",
|
| 31 |
+
"Programming Language :: Python :: Implementation :: PyPy",
|
| 32 |
+
"Operating System :: OS Independent",
|
| 33 |
+
"Typing :: Typed",
|
| 34 |
+
]
|
| 35 |
+
|
| 36 |
+
packages = [
|
| 37 |
+
{ include = "tinydb" },
|
| 38 |
+
{ include = "tests", format = "sdist" }
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
[tool.poetry.urls]
|
| 42 |
+
"Changelog" = "https://tinydb.readthedocs.io/en/latest/changelog.html"
|
| 43 |
+
"Issues" = "https://github.com/msiemens/tinydb/issues"
|
| 44 |
+
|
| 45 |
+
[tool.poetry.dependencies]
|
| 46 |
+
python = "^3.8"
|
| 47 |
+
|
| 48 |
+
[tool.poetry.dev-dependencies]
|
| 49 |
+
pytest = "^7.2.0"
|
| 50 |
+
pytest-pycodestyle = "^2.3.1"
|
| 51 |
+
pytest-cov = "^4.0.0"
|
| 52 |
+
pycodestyle = "^2.10.0"
|
| 53 |
+
sphinx = "^7.0.0"
|
| 54 |
+
coveralls = "^3.3.1"
|
| 55 |
+
pyyaml = "^6.0"
|
| 56 |
+
pytest-mypy = { version = "^0.10.2", markers = "platform_python_implementation != 'PyPy'" }
|
| 57 |
+
types-PyYAML = "^6.0.0"
|
| 58 |
+
|
| 59 |
+
[build-system]
|
| 60 |
+
requires = ["poetry-core"]
|
| 61 |
+
build-backend = "poetry.core.masonry.api"
|
tasks/msiemens__tinydb.10644a0e.func_basic__532t36or/tests/trusted/pytest.ini
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
addopts=--verbose --cov-append --cov-report term --cov tinydb
|