test_converters.py 文件源码

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

项目:PyKED 作者: pr-omethe-us 项目源码 文件源码
def test_error_rcm_pressurerise(self):
        """Test for appropriate error if RCM file has pressure rise.
        """
        file_path = os.path.join('testfile_rcm.xml')
        filename = pkg_resources.resource_filename(__name__, file_path)

        # add pressure rise to common properties
        tree = etree.parse(filename)
        root = tree.getroot()
        properties = root.find('commonProperties')
        prop = etree.SubElement(properties, 'property')
        prop.set('name', 'pressure rise')
        prop.set('units', '1/ms')
        prop_value = etree.SubElement(prop, 'value')
        prop_value.text = '0.10'

        # write new file, and try to load
        et = etree.ElementTree(root)
        with TemporaryDirectory() as temp_dir:
            filename = os.path.join(temp_dir, 'test.xml')
            et.write(filename, encoding='utf-8', xml_declaration=True)

            with pytest.raises(KeywordError) as excinfo:
                ReSpecTh_to_ChemKED(filename)
            assert 'Pressure rise cannot be defined for RCM.' in str(excinfo.value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号