then.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:microwebscraper 作者: codefortallahassee 项目源码 文件源码
def step_output_should_match_file(context, file_):
    with open(os.path.join(current_dir, file_)) as output:
        if file_.endswith('.json'):
            context.output = json.loads(context.output)
            output = json.load(output)
            try:
                eq_(context.output, output)
            except AssertionError:
                print(str(DictDiffer(context.output, output)))
                raise

        else:
            context = list(map(str.strip, context.output.splitlines()))
            expected_result = list(map(str.strip, output.readlines()))
            try:
                eq_(context, expected_result)
            except AssertionError:
                d = difflib.Differ()
                for line in d.compare(context, expected_result):
                    print(line)
                raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号