Example #1
0
class TestShowersLimitXMLHandler(unittest.TestCase):

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

        self.h = ShowersLimitXMLHandler()

        self.obj = ShowersLimit(123)

        etree.register_namespace('mc', 'http://pymontecarlo.sf.net')
        source = BytesIO(b'<mc:showersLimit xmlns:mc="http://pymontecarlo.sf.net" showers="123" />')
        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.assertEqual(123, obj.showers)

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

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

        self.assertAlmostEqual(123.0, float(element.get('showers')), 4)
Example #2
0
    def setUp(self):
        unittest.TestCase.setUp(self)

        self.h = ShowersLimitXMLHandler()

        self.obj = ShowersLimit(123)

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