Exemple #1
0
 def test_parse_duration_element(self):
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'Y'), 1)
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'M'), 2)
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'D'), 3)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'H'), 4)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'M'), 5)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'S'), 6.1234)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'H'), 4)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'M'), 54)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'S'), 6.5)
 def test_parse_duration_element(self):
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'Y'), 1)
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'M'), 2)
     self.assertEqual(_parse_duration_element('P1Y2M3D', 'D'), 3)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'H'), 4)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'M'), 5)
     self.assertEqual(_parse_duration_element('T4H5M6.1234S', 'S'), 6.1234)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'H'), 4)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'M'), 54)
     self.assertEqual(_parse_duration_element('PT4H54M6,5S', 'S'), 6.5)
Exemple #3
0
    def test_parse_duration_element(self):
        testtuples = (('P1Y2M3D', 'Y', '1'), ('P1Y2M3D', 'M', '2'),
                      ('P1Y2M3D', 'D', '3'), ('PT4H54M6,5S', 'H', '4'),
                      ('PT4H54M6,5S', 'M', '54'), ('PT4H54M6,5S', 'S', '6.5'),
                      ('T4H5M6.1234S', 'H', '4'), ('T4H5M6.1234S', 'M', '5'),
                      ('T4H5M6.1234S', 'S', '6.1234'))

        for testtuple in testtuples:
            self.assertEqual(
                _parse_duration_element(testtuple[0], testtuple[1]),
                testtuple[2])
    def test_parse_duration_element(self):
        testtuples = (
            ("P1Y2M3D", "Y", "1"),
            ("P1Y2M3D", "M", "2"),
            ("P1Y2M3D", "D", "3"),
            ("T4H5M6.1234S", "H", "4"),
            ("T4H5M6.1234S", "M", "5"),
            ("T4H5M6.1234S", "S", "6.1234"),
            ("PT4H54M6,5S", "H", "4"),
            ("PT4H54M6,5S", "M", "54"),
            ("PT4H54M6,5S", "S", "6.5"),
        )

        for testtuple in testtuples:
            self.assertEqual(
                _parse_duration_element(testtuple[0], testtuple[1]), testtuple[2]
            )