test_07_PythonParsers.py 文件源码

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

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def test_SPDParser(self):
        # Verify the input is valid
        spdPath = os.path.abspath("sdr/dom/components/CommandWrapper/CommandWrapper.spd.xml")
        status = self._xmllint(spdPath, "SPD")
        self.assertEqual(status, 0, "Input XML isn't DTD valid")

        spd = parsers.SPDParser.parse(spdPath)
        self.assertEqual(spd.get_id(), "DCE:458872f6-a316-4082-b1eb-ce5704f5c49d")
        self.assertEqual(spd.get_name(), "CommandWrapper")
        self.assertEqual(str(spd.get_author()[0].get_name()[0]), "REDHAWK test author")
        self.assertEqual(spd.get_propertyfile().get_type(), "PRF")
        self.assertEqual(spd.get_propertyfile().get_localfile().get_name(), "CommandWrapper.prf.xml")

        # Verify that we can write the output and still be DTD valid
        tmpfile = tempfile.mktemp()
        try:
            tmp = open(tmpfile, "w")
            spd.export(tmp, 0)
            tmp.close()
            status = self._xmllint(tmpfile, "SPD")
            self.assertEqual(status, 0, "Python parser did not emit DTD compliant XML")
        finally:
            try:
                os.remove(tmpfile)
            except OSError:
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号