test_converters.py 文件源码

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

项目:PyKED 作者: pr-omethe-us 项目源码 文件源码
def test_doi_missing_internet(self, disable_socket):
        """Ensure that DOI validation fails gracefully with no Internet.
        """
        root = etree.Element('experiment')
        ref = etree.SubElement(root, 'bibliographyLink')
        ref.set('doi', '10.1016/j.ijhydene.2007.04.008')
        ref.set('preferredKey', 'Chaumeix, N., Pichon, S., Lafosse, F., Paillard, C.-E., '
                'International Journal of Hydrogen Energy, 2007, (32) 2216-2226, '
                'Fig. 12., right, open diamond'
                )

        with pytest.warns(UserWarning) as record:
            ref = get_reference(root)
        m = str(record.pop(UserWarning).message)
        assert m == ('Missing doi attribute in bibliographyLink or lookup failed. Setting "detail" '
                     'key as a fallback; please update to the appropriate fields.')

        assert ref['detail'] == ('Chaumeix, N., Pichon, S., Lafosse, F., Paillard, C.-E., '
                                 'International Journal of Hydrogen Energy, 2007, (32) 2216-2226, '
                                 'Fig. 12., right, open diamond.'
                                 )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号