File tree Expand file tree Collapse file tree
pyrit/datasets/executors/question_answer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def fetch_wmdp_dataset(category: Optional[str] = None) -> QuestionAnsweringDatas
3131 """
3232 # Determine which subset of data to load
3333 data_categories = None
34- if not category : # if category is not specified, read in all 3 subsets of data
34+ if category is None : # if category is not specified, read in all 3 subsets of data
3535 data_categories = ["wmdp-cyber" , "wmdp-bio" , "wmdp-chem" ]
3636 elif category not in ["cyber" , "bio" , "chem" ]:
3737 raise ValueError (f"Invalid Parameter: { category } . Expected 'cyber', 'bio', or 'chem'" )
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation.
2+ # Licensed under the MIT license.
3+
4+ from unittest .mock import patch
5+
6+ import pytest
7+
8+ from pyrit .datasets .executors .question_answer .wmdp_dataset import fetch_wmdp_dataset
9+
10+
11+ class _EmptySplit :
12+ def __len__ (self ) -> int :
13+ return 0
14+
15+
16+ def test_fetch_wmdp_dataset_rejects_empty_category ():
17+ with patch (
18+ "pyrit.datasets.executors.question_answer.wmdp_dataset.load_dataset" ,
19+ return_value = {"test" : _EmptySplit ()},
20+ ) as mock_load_dataset :
21+ with pytest .raises (ValueError , match = "Invalid Parameter" ):
22+ fetch_wmdp_dataset (category = "" )
23+
24+ mock_load_dataset .assert_not_called ()
You can’t perform that action at this time.
0 commit comments