当前位置: 首页>>代码示例>>Python>>正文


Python Calculator._read_json_econ_assump_text方法代码示例

本文整理汇总了Python中taxcalc.Calculator._read_json_econ_assump_text方法的典型用法代码示例。如果您正苦于以下问题:Python Calculator._read_json_econ_assump_text方法的具体用法?Python Calculator._read_json_econ_assump_text怎么用?Python Calculator._read_json_econ_assump_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taxcalc.Calculator的用法示例。


在下文中一共展示了Calculator._read_json_econ_assump_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_response_json

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import _read_json_econ_assump_text [as 别名]
def test_response_json(tests_path):
    """
    Check that each JSON file can be converted into dictionaries that
    can be used to construct objects needed for a Calculator object.
    """
    # pylint: disable=too-many-locals
    responses_path = os.path.join(tests_path, '..', 'responses', '*.json')
    for jpf in glob.glob(responses_path):
        # read contents of jpf (JSON parameter filename)
        jfile = open(jpf, 'r')
        jpf_text = jfile.read()
        # check that jpf_text can be used to construct objects
        response_file = ('"consumption"' in jpf_text and
                         '"growdiff_baseline"' in jpf_text and
                         '"growdiff_response"' in jpf_text)
        if response_file:
            # pylint: disable=protected-access
            (con, gdiff_base,
             gdiff_resp) = Calculator._read_json_econ_assump_text(jpf_text)
            cons = Consumption()
            cons.update_consumption(con)
            growdiff_baseline = GrowDiff()
            growdiff_baseline.update_growdiff(gdiff_base)
            growdiff_response = GrowDiff()
            growdiff_response.update_growdiff(gdiff_resp)
        else:  # jpf_text is not a valid JSON response assumption file
            print('test-failing-filename: ' +
                  jpf)
            assert False
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:31,代码来源:test_responses.py


注:本文中的taxcalc.Calculator._read_json_econ_assump_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。