tests.py 文件源码

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

项目:ubuntu-standalone-builder 作者: OddBloke 项目源码 文件源码
def test_setup_teardown_content_matches_template(self, hook, monkeypatch):
        if list(self.kwargs.keys()) == ['binary_customisation_script']:
            pytest.skip('Test only applies to chroot hooks.')
        expected_string = '#!/bin/sh\n-- specific test content --'
        monkeypatch.setattr(
            generate_build_config,
            "{}_CONTENT".format(hook.upper()), expected_string)
        generate_build_config._write_cloud_config(
            open(self.output_file.strpath, 'w'), **self.kwargs)
        cloud_config = yaml.load(self.output_file.open())
        contents = [base64.b64decode(stanza['content'])
                    for stanza in cloud_config['write_files']]
        expected_bytes = expected_string.encode('utf-8')
        assert expected_bytes in contents
        assert 1 == len(
            [content for content in contents if expected_bytes == content])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号