Exemplo n.º 1
0
class TestTrajectoryDetectorXMLHandler(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.h = TrajectoryDetectorXMLHandler()

        self.obj = TrajectoryDetector(False)

        etree.register_namespace("mc", "http://pymontecarlo.sf.net")
        source = BytesIO(
            b'<mc:trajectoryDetector xmlns:mc="http://pymontecarlo.sf.net"><secondary>false</secondary></mc:trajectoryDetector>'
        )
        self.element = etree.parse(source).getroot()

    def tearDown(self):
        unittest.TestCase.tearDown(self)

    def testcan_parse(self):
        self.assertTrue(self.h.can_parse(self.element))

    def testparse(self):
        obj = self.h.parse(self.element)

        self.assertFalse(obj.secondary)

    def testcan_convert(self):
        self.assertTrue(self.h.can_convert(self.obj))

    def testconvert(self):
        element = self.h.convert(self.obj)

        subelement = element.find("secondary")
        self.assertEqual("false", subelement.text)
Exemplo n.º 2
0
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.h = TrajectoryDetectorXMLHandler()

        self.obj = TrajectoryDetector(False)

        etree.register_namespace("mc", "http://pymontecarlo.sf.net")
        source = BytesIO(
            b'<mc:trajectoryDetector xmlns:mc="http://pymontecarlo.sf.net"><secondary>false</secondary></mc:trajectoryDetector>'
        )
        self.element = etree.parse(source).getroot()