fileformatyaml_test.py 文件源码

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

项目:pypyr-cli 作者: pypyr 项目源码 文件源码
def test_fileformatyaml_pass_no_substitutions():
    """Relative path to file should succeed.

     Strictly speaking not a unit test.
    """
    context = Context({
        'ok1': 'ov1',
        'fileFormatYamlIn': './tests/testfiles/test.yaml',
        'fileFormatYamlOut': './tests/testfiles/out/out.yaml'})

    fileformat.run_step(context)

    assert context, "context shouldn't be None"
    assert len(context) == 3, "context should have 2 items"
    assert context['ok1'] == 'ov1'
    assert context['fileFormatYamlIn'] == './tests/testfiles/test.yaml'
    assert context['fileFormatYamlOut'] == './tests/testfiles/out/out.yaml'

    with open('./tests/testfiles/out/out.yaml') as outfile:
        outcontents = yaml.load(outfile, Loader=yaml.RoundTripLoader)

    assert len(outcontents) == 3
    assert outcontents['key'] == 'value1 !£$%# *'
    assert outcontents['key2'] == 'blah'
    assert outcontents['key3'] == ['l1',
                                   '!£$% *',
                                   'l2',
                                   [
                                       'l31',
                                       {'l32': ['l321', 'l322']}
                                   ]
                                   ]

    # atrociously lazy test clean-up
    os.remove('./tests/testfiles/out/out.yaml')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号