CrossSWE-Bench / scripts /reusable_support /inventory_policy.py
Silin-Chen's picture
CrossSWE-Bench: current 171-instance release
0e239c6
Raw History Blame Contribute Delete
1.18 kB
"""Allow only the upstream QUERY parametrization explicitly added by the frozen Flask gold."""
from collections import Counter
import hashlib
from pathlib import Path
def approved_gold_addition(task, label, baseline, fixed, inputs):
added=Counter(fixed)-Counter(baseline);removed=Counter(baseline)-Counter(fixed)
case='tests/test_basic.py::test_method_route[query]'
if task['instance_id']!='backend-flask-6133' or label!='flask-pass_to_pass' or removed or added!=Counter({case:1}):
return None
reference=next(r for r in task['repositories'] if r['key']=='flask')['gold_patch']
data=(Path(inputs)/reference['path']).read_bytes()
if hashlib.sha256(data).hexdigest()!=reference['sha256']:
return None
line=b'+@pytest.mark.parametrize("method", ["get", "query", "post", "put", "delete", "patch"])'
if line not in data.splitlines():
return None
return {'kind':'frozen-gold-added-upstream-test','added_cases':[case],'removed_cases':[],
'gold_patch':reference,'common_case_count':len(baseline),
'reason':'The unchanged frozen gold adds the QUERY parametrization in an already selected P2P file.'}