本文整理汇总了Python中taxcalc.Policy._validate_values方法的典型用法代码示例。如果您正苦于以下问题:Python Policy._validate_values方法的具体用法?Python Policy._validate_values怎么用?Python Policy._validate_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Policy
的用法示例。
在下文中一共展示了Policy._validate_values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_valid_value_infomation
# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import _validate_values [as 别名]
def test_valid_value_infomation():
"""
Check consistency of valid_values info in policy_current_law.json file.
"""
# pylint: disable=too-many-statements,too-many-locals
# pylint: disable=too-many-branches,too-many-nested-blocks
# construct set of parameter names with a "valid_values" field
policy = Policy()
min_max_list = ['min', 'max']
warn_stop_list = ['warn', 'stop']
json_range_params = set()
parameters = set(policy._vals.keys())
for pname, param in policy._vals.items():
assert isinstance(param, dict)
if param['value_type'] == 'string':
continue # because string parameters have no invalid_* keys
prange = param.get('valid_values', None)
if prange:
json_range_params.add(pname)
oor_action = param['invalid_action']
assert oor_action in warn_stop_list
range_items = prange.items()
assert len(range_items) == 2
for vop, vval in range_items:
assert vop in min_max_list
if isinstance(vval, str):
if vval == 'default':
if vop != 'min' or oor_action != 'warn':
msg = 'USES DEFAULT FOR min OR FOR error'
assert pname == msg
continue
else:
vval_ = '_' + vval
if vval_ in parameters:
if vop == 'min':
extra_msg = param['invalid_minmsg']
if vop == 'max':
extra_msg = param['invalid_maxmsg']
assert vval in extra_msg
else:
assert vval == 'ILLEGAL RANGE STRING VALUE'
else: # if vval is not a str
if isinstance(vval, int):
continue
elif isinstance(vval, float):
continue
elif isinstance(vval, bool):
continue
else:
assert vval == 'ILLEGAL RANGE NUMERIC VALUE'
# compare contents of c_l_p.json parameters and json_range_params
unmatched = parameters ^ json_range_params
if unmatched:
assert unmatched == 'UNMATCHED RANGE PARAMETERS'
# check all current-law-policy parameters for range validity
clp = Policy()
clp._validate_values(parameters)
# eventually activate: assert not clp.parameter_warnings
ctc_c_warning = 'CTC_c was redefined in release 1.0.0\n'
assert clp.parameter_warnings == ctc_c_warning
assert not clp.parameter_errors