File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
22from pathlib import Path
3- from typing import cast
3+ from typing import TypedDict , cast
44
55# Path to the shared testcases directory in athena-protobufs
66_REPO_ROOT = Path (__file__ ).parent .parent .parent .parent .parent
77TESTCASES_DIR = _REPO_ROOT / "athena-protobufs" / "testcases"
88
99
10+ class TestCases (TypedDict ):
11+ classification_labels : list [str ]
12+ images : list [list [str | list [float ]]]
13+
14+
1015class AthenaTestCase :
1116 def __init__ (
1217 self ,
@@ -28,13 +33,9 @@ def load_test_cases(dirname: str = "benign_model") -> list[AthenaTestCase]:
2833 with Path .open (
2934 Path (TESTCASES_DIR / dirname / "expected_outputs.json" ),
3035 ) as f :
31- test_cases = cast (
32- "dict[str, list[str] | list[list[str | list[float]]]]" , json .load (f )
33- )
34- classification_labels = cast (
35- "list[str]" , test_cases ["classification_labels" ]
36- )
37- images = cast ("list[list[str | list[float]]]" , test_cases ["images" ])
36+ test_cases : TestCases = cast ("TestCases" , json .load (f ))
37+ classification_labels = test_cases ["classification_labels" ]
38+ images = test_cases ["images" ]
3839 return [
3940 AthenaTestCase (
4041 str (
Original file line number Diff line number Diff line change 88import grpc .aio
99import numpy as np
1010import pytest
11-
12- from resolver_athena_client .client .athena_client import AthenaClient
13- from resolver_athena_client .client .athena_options import AthenaOptions
14- from resolver_athena_client .client .exceptions import AthenaError
15- from resolver_athena_client .client .models import ImageData
1611from resolver_athena_client .generated .athena .models_pb2 import (
1712 Classification ,
1813 ClassificationError ,
2520 RequestEncoding ,
2621)
2722
23+ from resolver_athena_client .client .athena_client import AthenaClient
24+ from resolver_athena_client .client .athena_options import AthenaOptions
25+ from resolver_athena_client .client .exceptions import AthenaError
26+ from resolver_athena_client .client .models import ImageData
27+
2828
2929@pytest .fixture
3030def athena_options () -> AthenaOptions :
You can’t perform that action at this time.
0 commit comments