This is the current datacheck decorator used widely in our test factories
def datacheck(func):
"""Overrides the data creator functions in this class to return 1 value
If run_one_datapoint=false, return the entire data set. (default: False)
If run_one_datapoint=true, return a random data.
"""
@wraps(func)
def func_wrapper(*args, **kwargs):
"""Perform smoke test attribute check"""
dataset = func(*args, **kwargs)
if settings.run_one_datapoint:
dataset = [random.choice(dataset)]
return dataset
return func_wrapper
When I read the name datacheck I imagine some checks being done in data or maybe some validation but actually it is just filtering he data randomly if the run_one_datapoint config option is set to true.
I was thinking if this is not a good idea to change the name of this decorator to something more explicit.
def datapoint_filtered(func):
"""Overrides the data creator functions in this class to return 1 value
If run_one_datapoint=false, return the entire data set. (default: False)
If run_one_datapoint=true, return a random data.
"""
ideas?
I fell the same when reading that decorator name. I would suggest something like one_datapoint or maybe smart_datapoint then the docstring would compliment what smart means.
And yes, naming is hard :smile:
@rochacbruno how about filtered_data or filtered_datapoint?
@omaciel @elyezer @abalakh I like filtered_datapoint
I totally missed this issue. datafilter would have suited as well.
Most helpful comment
@omaciel @elyezer @abalakh I like filtered_datapoint