| 882 | |
| 883 | |
| 884 | class WycheproofTest: |
| 885 | def __init__(self, testfiledata, testgroup, testcase): |
| 886 | self.testfiledata = testfiledata |
| 887 | self.testgroup = testgroup |
| 888 | self.testcase = testcase |
| 889 | |
| 890 | def __repr__(self): |
| 891 | return "<WycheproofTest({!r}, {!r}, {!r}, tcId={})>".format( |
| 892 | self.testfiledata, |
| 893 | self.testgroup, |
| 894 | self.testcase, |
| 895 | self.testcase["tcId"], |
| 896 | ) |
| 897 | |
| 898 | @property |
| 899 | def valid(self) -> bool: |
| 900 | return self.testcase["result"] == "valid" |
| 901 | |
| 902 | @property |
| 903 | def acceptable(self) -> bool: |
| 904 | return self.testcase["result"] == "acceptable" |
| 905 | |
| 906 | @property |
| 907 | def invalid(self) -> bool: |
| 908 | return self.testcase["result"] == "invalid" |
| 909 | |
| 910 | def has_flag(self, flag: str) -> bool: |
| 911 | return flag in self.testcase["flags"] |
| 912 | |
| 913 | def cache_value_to_group(self, cache_key: str, func): |
| 914 | cache_val = self.testgroup.get(cache_key) |
| 915 | if cache_val is not None: |
| 916 | return cache_val |
| 917 | self.testgroup[cache_key] = cache_val = func() |
| 918 | return cache_val |
| 919 | |
| 920 | |
| 921 | def load_wycheproof_tests(wycheproof, test_file): |
no outgoing calls