@@ -142,29 +142,31 @@ def is_sig_stfl_enabled_by_name(name):
142142 return True
143143 return False
144144
145+ # TODO: this function needs a refactor because the scan logic currently applies
146+ # re.findall to all args/kwargs in the wrapped function. If the function takes
147+ # a non-string argument, re.findall will raise a TypeError, which is
148+ # undesirable. It can also cause incorrect skipping if the wrapped function
149+ # takes some string argument that unintentionally matches the regex.
150+ # Instead, I prefer replacing this decorator with a regular function that returns
151+ # a boolean indicating whether a KEM/SIG/STFL_SIG name matches the env var
152+ # SKIP_ALGS, then let the caller decide whether to call pytest.skip.
145153def filtered_test (func ):
146- funcname = func .__name__ [len ("test_" ) :]
154+ funcname = func .__name__ [len ("test_" ):]
147155
148156 @functools .wraps (func )
149157 def wrapper (* args , ** kwargs ):
150- if (" SKIP_ALGS" in os .environ ) and len (os .environ [" SKIP_ALGS" ]) > 0 :
151- for algexp in os .environ [" SKIP_ALGS" ].split ("," ):
158+ if (' SKIP_ALGS' in os .environ ) and len (os .environ [' SKIP_ALGS' ]) > 0 :
159+ for algexp in os .environ [' SKIP_ALGS' ].split (',' ):
152160 for arg in args :
153- if isinstance ( arg , str ) and len (re .findall (algexp , arg )) > 0 :
161+ if len (re .findall (algexp , arg ))> 0 :
154162 pytest .skip ("Test disabled by alg filter" )
155163 for arg in kwargs :
156- if (
157- isinstance (kwargs [arg ], str )
158- and len (re .findall (algexp , kwargs [arg ])) > 0
159- ):
164+ if len (re .findall (algexp , kwargs [arg ]))> 0 :
160165 pytest .skip ("Test disabled by alg filter" )
161- if ("SKIP_TESTS" in os .environ ) and (
162- funcname in os .environ ["SKIP_TESTS" ].lower ().split ("," )
163- ):
166+ if ('SKIP_TESTS' in os .environ ) and (funcname in os .environ ['SKIP_TESTS' ].lower ().split (',' )):
164167 pytest .skip ("Test disabled by filter" )
165168 else :
166169 return func (* args , ** kwargs )
167-
168170 return wrapper
169171
170172# So far, build dir name has been hard coded to "build".
0 commit comments