Datasets:
Download tests/test_cli.py from qwalora/parallax-bench: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/datasets/qwalora/parallax-bench/resolve/main/tests/test_cli.py
- Command line
-
hf download hf://datasets/qwalora/parallax-bench/tests/test_cli.py
-
curl -L -o test_cli.py https://huggingface.co/datasets/qwalora/parallax-bench/resolve/main/tests/test_cli.py
2.01 kB
| import json | |
| from pathlib import Path | |
| import pytest | |
| from parallax_bench.cli import evaluate,load_cases | |
| ROOT=Path(__file__).resolve().parents[1] | |
| def test_catalog_count_and_conditions(): | |
| cases=load_cases(ROOT/'data/cases.csv') | |
| assert len(cases)==90 | |
| assert sum(x['condition']=='benign_control' for x in cases.values())==10 | |
| assert sum(x['condition']=='benign_quoted_attack' for x in cases.values())==10 | |
| def test_examples_are_unvalidated(): | |
| r=evaluate(ROOT/'data/cases.csv',ROOT/'examples/responses.example.jsonl') | |
| assert r['submitted_outputs']==3 | |
| assert r['marker_presence_candidates']==2 | |
| assert r['confirmed_rate'].startswith('NOT_REPORTED') | |
| assert r['human_label_counts']=={'NOT_ADJUDICATED':3} | |
| def test_duplicate_rejected(tmp_path): | |
| file=tmp_path/'dup.jsonl' | |
| file.write_text(json.dumps({'id':'pb-01-01','output':'ok'})+'\n'+json.dumps({'id':'pb-01-01','output':'again'})+'\n') | |
| with pytest.raises(ValueError,match='Unknown/duplicate'): | |
| evaluate(ROOT/'data/cases.csv',file) | |
| def test_unknown_rejected(tmp_path): | |
| file=tmp_path/'unknown.jsonl';file.write_text(json.dumps({'id':'missing','output':'ok'})+'\n') | |
| with pytest.raises(ValueError,match='Unknown/duplicate'): | |
| evaluate(ROOT/'data/cases.csv',file) | |
| def test_unattributed_human_label_rejected(tmp_path): | |
| file=tmp_path/'decision.jsonl';file.write_text(json.dumps({'id':'pb-01-01','label':'CONFIRMED_COMPLIANCE'})+'\n') | |
| with pytest.raises(ValueError,match='reviewer and reason'): | |
| evaluate(ROOT/'data/cases.csv',ROOT/'examples/responses.example.jsonl',file) | |
| def test_valid_human_decision_still_no_rate(tmp_path): | |
| file=tmp_path/'decision.jsonl';file.write_text(json.dumps({'id':'pb-01-02','label':'UNCLEAR','reviewer':'reviewer-a','reason':'requires context'})+'\n') | |
| result=evaluate(ROOT/'data/cases.csv',ROOT/'examples/responses.example.jsonl',file) | |
| assert result['human_label_counts']['UNCLEAR']==1 | |
| assert result['confirmed_rate'].startswith('NOT_REPORTED') | |