Exemplo n.º 1
0
    def test_parse_time_mockbuilder(self):
        mockBuilder = mock.Mock()

        expectedargs = {'hh': '01', 'mm': '23', 'ss': '45', 'tz': None}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('01:23:45', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {'hh': '23', 'mm': '21', 'ss': '28.512400',
                        'tz': (False, None, '00', '00', '+00:00', 'timezone')}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('232128.512400+00:00', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {'hh': '23', 'mm': '21', 'ss': '28.512400',
                        'tz': (False, None, '11', '15', '+11:15', 'timezone')}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('23:21:28.512400+11:15', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)
    def test_parse_time_mockbuilder(self):
        mockBuilder = mock.Mock()

        expectedargs = {'hh': '01', 'mm': '23', 'ss': '45', 'tz': None}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('01:23:45', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {'hh': '23', 'mm': '21', 'ss': '28.512400',
                        'tz': (False, None, '00', '00', '+00:00', 'timezone')}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('232128.512400+00:00', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {'hh': '23', 'mm': '21', 'ss': '28.512400',
                        'tz': (False, None, '11', '15', '+11:15', 'timezone')}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time('23:21:28.512400+11:15', builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)
Exemplo n.º 3
0
    def test_parse_time_badstr(self):
        testtuples = ('A6:14:00.000123Z', '06:14:0B', '06:1 :02',
                      '0000,70:24,9', '00.27:5332', 'bad', '')

        for testtuple in testtuples:
            with self.assertRaises(ISOFormatError):
                parse_time(testtuple, builder=None)
Exemplo n.º 4
0
    def test_parse_datetime_badstr(self):
        testtuples = ('1981-04-05TA6:14:00.000123Z', '2004-W53-6T06:14:0B',
                      '2014-01-230T23:21:28+00', '201401230T01:03:11.858714',
                      'bad', '')

        for testtuple in testtuples:
            with self.assertRaises(ISOFormatError):
                parse_time(testtuple, builder=None)
Exemplo n.º 5
0
    def test_parse_time_badstr(self):
        testtuples = (
            "A6:14:00.000123Z",
            "06:14:0B",
            "06:1 :02",
            "0000,70:24,9",
            "00.27:5332",
            "bad",
            "",
        )

        for testtuple in testtuples:
            with self.assertRaises(ISOFormatError):
                parse_time(testtuple, builder=None)
Exemplo n.º 6
0
def _parse_duration_combined(durationstr, relative):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T')  #We skip the 'P'

    datevalue = parse_date(datepart)
    timevalue = parse_time(timepart)

    if relative is True:
        try:
            import dateutil.relativedelta

            return dateutil.relativedelta.relativedelta(
                years=datevalue.year,
                months=datevalue.month,
                days=datevalue.day,
                hours=timevalue.hour,
                minutes=timevalue.minute,
                seconds=timevalue.second,
                microseconds=timevalue.microsecond)
        except ImportError:
            raise RuntimeError(
                'dateutil must be installed for relative duration support.')
    else:
        totaldays = datevalue.year * 365 + datevalue.month * 30 + datevalue.day

        return datetime.timedelta(days=totaldays,
                                  hours=timevalue.hour,
                                  minutes=timevalue.minute,
                                  seconds=timevalue.second,
                                  microseconds=timevalue.microsecond)
Exemplo n.º 7
0
    def test_parse_time_mockbuilder(self):
        mockBuilder = mock.Mock()

        expectedargs = {"hh": "01", "mm": "23", "ss": "45", "tz": None}

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time("01:23:45", builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {
            "hh": "23",
            "mm": "21",
            "ss": "28.512400",
            "tz": (False, None, "00", "00", "+00:00", "timezone"),
        }

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time("232128.512400+00:00", builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)

        mockBuilder = mock.Mock()

        expectedargs = {
            "hh": "23",
            "mm": "21",
            "ss": "28.512400",
            "tz": (False, None, "11", "15", "+11:15", "timezone"),
        }

        mockBuilder.build_time.return_value = expectedargs

        result = parse_time("23:21:28.512400+11:15", builder=mockBuilder)

        self.assertEqual(result, expectedargs)
        mockBuilder.build_time.assert_called_once_with(**expectedargs)
Exemplo n.º 8
0
def _parse_duration_combined(durationstr, builder):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T') #We skip the 'P'

    datevalue = parse_date(datepart, builder=TupleBuilder)
    timevalue = parse_time(timepart, builder=TupleBuilder)

    return builder.build_duration(PnY=datevalue[0], PnM=datevalue[1],
                                  PnD=datevalue[2], TnH=timevalue[0],
                                  TnM=timevalue[1], TnS=timevalue[2])
Exemplo n.º 9
0
def _parse_duration_combined(durationstr):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T') #We skip the 'P'

    datevalue = parse_date(datepart)
    timevalue = parse_time(timepart)

    totaldays = datevalue.year * 365 + datevalue.month * 30 + datevalue.day

    return datetime.timedelta(days=totaldays, hours=timevalue.hour, minutes=timevalue.minute, seconds=timevalue.second, microseconds=timevalue.microsecond)
Exemplo n.º 10
0
def _parse_duration_combined(durationstr, builder):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T') #We skip the 'P'

    datevalue = parse_date(datepart, builder=TupleBuilder)
    timevalue = parse_time(timepart, builder=TupleBuilder)

    return builder.build_duration(PnY=datevalue[0], PnM=datevalue[1],
                                  PnD=datevalue[2], TnH=timevalue[0],
                                  TnM=timevalue[1], TnS=timevalue[2])
def _parse_duration_combined(durationstr):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T')  #We skip the 'P'

    datevalue = parse_date(datepart)
    timevalue = parse_time(timepart)

    totaldays = datevalue.year * 365 + datevalue.month * 30 + datevalue.day

    return datetime.timedelta(days=totaldays,
                              hours=timevalue.hour,
                              minutes=timevalue.minute,
                              seconds=timevalue.second,
                              microseconds=timevalue.microsecond)
Exemplo n.º 12
0
def _parse_duration_combined(durationstr):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T', 1)  #We skip the 'P'

    datevalue = parse_date(datepart, builder=TupleBuilder)
    timevalue = parse_time(timepart, builder=TupleBuilder)

    return {
        'PnY': datevalue.YYYY,
        'PnM': datevalue.MM,
        'PnD': datevalue.DD,
        'TnH': timevalue.hh,
        'TnM': timevalue.mm,
        'TnS': timevalue.ss
    }
Exemplo n.º 13
0
def _parse_duration_combined(durationstr):
    # Period of the form P<date>T<time>

    # Split the string in to its component parts
    datepart, timepart = durationstr[1:].split("T", 1)  # We skip the 'P'

    datevalue = parse_date(datepart, builder=TupleBuilder)
    timevalue = parse_time(timepart, builder=TupleBuilder)

    return {
        "PnY": datevalue.YYYY,
        "PnM": datevalue.MM,
        "PnD": datevalue.DD,
        "TnH": timevalue.hh,
        "TnM": timevalue.mm,
        "TnS": timevalue.ss,
    }
Exemplo n.º 14
0
def _parse_duration_combined(durationstr, relative):
    #Period of the form P<date>T<time>

    #Split the string in to its component parts
    datepart, timepart = durationstr[1:].split('T') #We skip the 'P'

    datevalue = parse_date(datepart)
    timevalue = parse_time(timepart)

    if relative is True:
        try:
            import dateutil.relativedelta

            return dateutil.relativedelta.relativedelta(years=datevalue.year, months=datevalue.month, days=datevalue.day, hours=timevalue.hour, minutes=timevalue.minute, seconds=timevalue.second, microseconds=timevalue.microsecond)
        except ImportError:
            raise RuntimeError('dateutil must be installed for relative duration support.')
    else:
        totaldays = datevalue.year * 365 + datevalue.month * 30 + datevalue.day

        return datetime.timedelta(days=totaldays, hours=timevalue.hour, minutes=timevalue.minute, seconds=timevalue.second, microseconds=timevalue.microsecond)
Exemplo n.º 15
0
    def test_parse_time(self):
        testtuples = (('01:23:45', {
            'hh': '01',
            'mm': '23',
            'ss': '45',
            'tz': None
        }), ('24:00:00', {
            'hh': '24',
            'mm': '00',
            'ss': '00',
            'tz': None
        }), ('23:21:28.512400', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': None
        }), ('01:03:11.858714', {
            'hh': '01',
            'mm': '03',
            'ss': '11.858714',
            'tz': None
        }), ('14:43:59.9999997', {
            'hh': '14',
            'mm': '43',
            'ss': '59.9999997',
            'tz': None
        }), ('01:23', {
            'hh': '01',
            'mm': '23',
            'tz': None
        }), ('24:00', {
            'hh': '24',
            'mm': '00',
            'tz': None
        }), ('01:23.4567', {
            'hh': '01',
            'mm': '23.4567',
            'tz': None
        }), ('012345', {
            'hh': '01',
            'mm': '23',
            'ss': '45',
            'tz': None
        }), ('240000', {
            'hh': '24',
            'mm': '00',
            'ss': '00',
            'tz': None
        }), ('232128.512400', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': None
        }), ('010311.858714', {
            'hh': '01',
            'mm': '03',
            'ss': '11.858714',
            'tz': None
        }), ('144359.9999997', {
            'hh': '14',
            'mm': '43',
            'ss': '59.9999997',
            'tz': None
        }), ('0123', {
            'hh': '01',
            'mm': '23',
            'tz': None
        }), ('2400', {
            'hh': '24',
            'mm': '00',
            'tz': None
        }), ('01', {
            'hh': '01',
            'tz': None
        }), ('24', {
            'tz': None
        }), ('12.5', {
            'hh': '12.5',
            'tz': None
        }), ('232128.512400+00:00', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('0123.4567+00:00', {
            'hh': '01',
            'mm': '23.4567',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('01.4567+00:00', {
            'hh': '01.4567',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('01:23:45+00:00', {
            'hh': '01',
            'mm': '23',
            'ss': '45',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('24:00:00+00:00', {
            'hh': '24',
            'mm': '00',
            'ss': '00',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('23:21:28.512400+00:00', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('01:23+00:00', {
            'hh': '01',
            'mm': '23',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('24:00+00:00', {
            'hh': '24',
            'mm': '00',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('01:23.4567+00:00', {
            'hh': '01',
            'mm': '23.4567',
            'tz': (False, None, '00', '00', '+00:00', 'timezone')
        }), ('23:21:28.512400+11:15', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': (False, None, '11', '15', '+11:15', 'timezone')
        }), ('23:21:28.512400-12:34', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': (True, None, '12', '34', '-12:34', 'timezone')
        }), ('23:21:28.512400Z', {
            'hh': '23',
            'mm': '21',
            'ss': '28.512400',
            'tz': (False, True, None, None, 'Z', 'timezone')
        }), ('06:14:00.000123Z', {
            'hh': '06',
            'mm': '14',
            'ss': '00.000123',
            'tz': (False, True, None, None, 'Z', 'timezone')
        }))

        for testtuple in testtuples:
            with mock.patch.object(aniso8601.time.PythonTimeBuilder,
                                   'build_time') as mockBuildTime:
                mockBuildTime.return_value = testtuple[1]

                result = parse_time(testtuple[0])

                self.assertEqual(result, testtuple[1])
                mockBuildTime.assert_called_once_with(**testtuple[1])
Exemplo n.º 16
0
    def test_parse_time(self):
        time = parse_time('01:23:45')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)

        time = parse_time('24:00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)

        time = parse_time('23:21:28.512400')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)

        time = parse_time('01:23')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)

        time = parse_time('24:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)

        time = parse_time('01:23.4567')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)

        time = parse_time('012345')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)

        time = parse_time('240000')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)

        time = parse_time('0123')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)

        time = parse_time('2400')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)

        time = parse_time('01')
        self.assertEqual(time.hour, 1)

        time = parse_time('24')
        self.assertEqual(time.hour, 0)

        time = parse_time('12.5')
        self.assertEqual(time.hour, 12)
        self.assertEqual(time.minute, 30)

        time = parse_time('232128.512400+00:00')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('0123.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 27)
        self.assertEqual(time.second, 24)
        self.assertEqual(time.microsecond, 120000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23:45+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00:00+00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+00:00')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00+00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+11:15')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=11, minutes=15))
        self.assertEqual(tzinfoobject.tzname(None), '+11:15')

        time = parse_time('23:21:28.512400-12:34')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         -datetime.timedelta(hours=12, minutes=34))
        self.assertEqual(tzinfoobject.tzname(None), '-12:34')

        time = parse_time('23:21:28.512400Z')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), 'UTC')

        time = parse_time('06:14:00.000123Z')
        self.assertEqual(time.hour, 6)
        self.assertEqual(time.minute, 14)
        self.assertEqual(time.second, 00)
        self.assertEqual(time.microsecond, 123)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), 'UTC')
Exemplo n.º 17
0
def _parse_interval_end(endstr, starttuple, datetimedelimiter):
    datestr = None
    timestr = None

    monthstr = None
    daystr = None

    concise = False

    if type(starttuple) is DateTuple:
        startdatetuple = starttuple
    else:
        #Start is a datetime
        startdatetuple = starttuple.date

    if datetimedelimiter in endstr:
        datestr, timestr = endstr.split(datetimedelimiter, 1)
    elif ':' in endstr:
        timestr = endstr
    else:
        datestr = endstr

    if timestr is not None:
        endtimetuple = parse_time(timestr, builder=TupleBuilder)

    #End is just a time
    if datestr is None:
        return endtimetuple

    #Handle backwards concise representation
    if datestr.count('-') == 1:
        monthstr, daystr = datestr.split('-')
        concise = True
    elif len(datestr) <= 2:
        daystr = datestr
        concise = True
    elif len(datestr) <= 4:
        monthstr = datestr[0:2]
        daystr = datestr[2:]
        concise = True

    if concise is True:
        concisedatestr = startdatetuple.YYYY

        #Separators required because concise elements may be missing digits
        if monthstr is not None:
            concisedatestr += '-' + monthstr
        elif startdatetuple.MM is not None:
            concisedatestr += '-' + startdatetuple.MM

        concisedatestr += '-' + daystr

        enddatetuple = parse_date(concisedatestr, builder=TupleBuilder)

        #Clear unsupplied components
        if monthstr is None:
            enddatetuple = TupleBuilder.build_date(DD=enddatetuple.DD)
        else:
            #Year not provided
            enddatetuple = TupleBuilder.build_date(MM=enddatetuple.MM,
                                                   DD=enddatetuple.DD)
    else:
        enddatetuple = parse_date(datestr, builder=TupleBuilder)

    if timestr is None:
        return enddatetuple

    return TupleBuilder.build_datetime(enddatetuple, endtimetuple)
Exemplo n.º 18
0
    def test_parse_time(self):
        testtuples = (
            ("01:23:45", {
                "hh": "01",
                "mm": "23",
                "ss": "45",
                "tz": None
            }),
            ("24:00:00", {
                "hh": "24",
                "mm": "00",
                "ss": "00",
                "tz": None
            }),
            ("23:21:28,512400", {
                "hh": "23",
                "mm": "21",
                "ss": "28.512400",
                "tz": None
            }),
            ("23:21:28.512400", {
                "hh": "23",
                "mm": "21",
                "ss": "28.512400",
                "tz": None
            }),
            ("01:03:11.858714", {
                "hh": "01",
                "mm": "03",
                "ss": "11.858714",
                "tz": None
            }),
            (
                "14:43:59.9999997",
                {
                    "hh": "14",
                    "mm": "43",
                    "ss": "59.9999997",
                    "tz": None
                },
            ),
            ("01:23", {
                "hh": "01",
                "mm": "23",
                "tz": None
            }),
            ("24:00", {
                "hh": "24",
                "mm": "00",
                "tz": None
            }),
            ("01:23,4567", {
                "hh": "01",
                "mm": "23.4567",
                "tz": None
            }),
            ("01:23.4567", {
                "hh": "01",
                "mm": "23.4567",
                "tz": None
            }),
            ("012345", {
                "hh": "01",
                "mm": "23",
                "ss": "45",
                "tz": None
            }),
            ("240000", {
                "hh": "24",
                "mm": "00",
                "ss": "00",
                "tz": None
            }),
            ("232128,512400", {
                "hh": "23",
                "mm": "21",
                "ss": "28.512400",
                "tz": None
            }),
            ("232128.512400", {
                "hh": "23",
                "mm": "21",
                "ss": "28.512400",
                "tz": None
            }),
            ("010311.858714", {
                "hh": "01",
                "mm": "03",
                "ss": "11.858714",
                "tz": None
            }),
            ("144359.9999997", {
                "hh": "14",
                "mm": "43",
                "ss": "59.9999997",
                "tz": None
            }),
            ("0123", {
                "hh": "01",
                "mm": "23",
                "tz": None
            }),
            ("2400", {
                "hh": "24",
                "mm": "00",
                "tz": None
            }),
            ("01", {
                "hh": "01",
                "tz": None
            }),
            ("24", {
                "tz": None
            }),
            ("12,5", {
                "hh": "12.5",
                "tz": None
            }),
            ("12.5", {
                "hh": "12.5",
                "tz": None
            }),
            (
                "232128,512400+00:00",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "232128.512400+00:00",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "0123,4567+00:00",
                {
                    "hh": "01",
                    "mm": "23.4567",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "0123.4567+00:00",
                {
                    "hh": "01",
                    "mm": "23.4567",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "01,4567+00:00",
                {
                    "hh": "01.4567",
                    "tz": (False, None, "00", "00", "+00:00", "timezone")
                },
            ),
            (
                "01.4567+00:00",
                {
                    "hh": "01.4567",
                    "tz": (False, None, "00", "00", "+00:00", "timezone")
                },
            ),
            (
                "01:23:45+00:00",
                {
                    "hh": "01",
                    "mm": "23",
                    "ss": "45",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "24:00:00+00:00",
                {
                    "hh": "24",
                    "mm": "00",
                    "ss": "00",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "23:21:28.512400+00:00",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "01:23+00:00",
                {
                    "hh": "01",
                    "mm": "23",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "24:00+00:00",
                {
                    "hh": "24",
                    "mm": "00",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "01:23.4567+00:00",
                {
                    "hh": "01",
                    "mm": "23.4567",
                    "tz": (False, None, "00", "00", "+00:00", "timezone"),
                },
            ),
            (
                "23:21:28.512400+11:15",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (False, None, "11", "15", "+11:15", "timezone"),
                },
            ),
            (
                "23:21:28.512400-12:34",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (True, None, "12", "34", "-12:34", "timezone"),
                },
            ),
            (
                "23:21:28.512400Z",
                {
                    "hh": "23",
                    "mm": "21",
                    "ss": "28.512400",
                    "tz": (False, True, None, None, "Z", "timezone"),
                },
            ),
            (
                "06:14:00.000123Z",
                {
                    "hh": "06",
                    "mm": "14",
                    "ss": "00.000123",
                    "tz": (False, True, None, None, "Z", "timezone"),
                },
            ),
        )

        for testtuple in testtuples:
            with mock.patch.object(aniso8601.time.PythonTimeBuilder,
                                   "build_time") as mockBuildTime:

                mockBuildTime.return_value = testtuple[1]

                result = parse_time(testtuple[0])

                self.assertEqual(result, testtuple[1])
                mockBuildTime.assert_called_once_with(**testtuple[1])
Exemplo n.º 19
0
    def test_parse_time(self):
        time = parse_time('01:23:45')
        self.assertEqual(time, datetime.time(hour=1, minute=23, second=45))

        time = parse_time('24:00:00')
        self.assertEqual(time, datetime.time(hour=0))

        time = parse_time('23:21:28.512400')
        self.assertEqual(
            time,
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        time = parse_time('14:43:59.9999997')
        self.assertEqual(
            time,
            datetime.time(hour=14, minute=43, second=59, microsecond=999999))

        time = parse_time('01:23')
        self.assertEqual(time, datetime.time(hour=1, minute=23))

        time = parse_time('24:00')
        self.assertEqual(time, datetime.time(hour=0))

        time = parse_time('01:23.4567')
        self.assertEqual(
            time,
            datetime.time(hour=1, minute=23, second=27, microsecond=402000))

        time = parse_time('012345')
        self.assertEqual(time, datetime.time(hour=1, minute=23, second=45))

        time = parse_time('240000')
        self.assertEqual(time, datetime.time(hour=0))

        time = parse_time('144359.9999997')
        self.assertEqual(
            time,
            datetime.time(hour=14, minute=43, second=59, microsecond=999999))

        time = parse_time('0123')
        self.assertEqual(time, datetime.time(hour=1, minute=23))

        time = parse_time('2400')
        self.assertEqual(time, datetime.time(hour=0))

        time = parse_time('01')
        self.assertEqual(time, datetime.time(hour=1))

        time = parse_time('24')
        self.assertEqual(time, datetime.time(hour=0))

        time = parse_time('12.5')
        self.assertEqual(time, datetime.time(hour=12, minute=30))

        time = parse_time('232128.512400+00:00')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('0123.4567+00:00')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=1, minute=23, second=27, microsecond=402000))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01.4567+00:00')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=1, minute=27, second=24, microsecond=120000))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23:45+00:00')
        self.assertEqual(time.replace(tzinfo=None),
                         datetime.time(hour=1, minute=23, second=45))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00:00+00:00')
        self.assertEqual(time.replace(tzinfo=None), datetime.time(hour=0))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+00:00')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23+00:00')
        self.assertEqual(time.replace(tzinfo=None),
                         datetime.time(hour=1, minute=23))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00+00:00')
        self.assertEqual(time.replace(tzinfo=None), datetime.time(hour=0))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23.4567+00:00')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=1, minute=23, second=27, microsecond=402000))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+11:15')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=11, minutes=15))
        self.assertEqual(tzinfoobject.tzname(None), '+11:15')

        time = parse_time('23:21:28.512400-12:34')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         -datetime.timedelta(hours=12, minutes=34))
        self.assertEqual(tzinfoobject.tzname(None), '-12:34')

        time = parse_time('23:21:28.512400Z')
        self.assertEqual(
            time.replace(tzinfo=None),
            datetime.time(hour=23, minute=21, second=28, microsecond=512400))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), 'UTC')

        time = parse_time('06:14:00.000123Z')
        self.assertEqual(time.replace(tzinfo=None),
                         datetime.time(hour=6, minute=14, microsecond=123))

        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None),
                         datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), 'UTC')
Exemplo n.º 20
0
    def test_parse_time_bounds(self):
        #Leap seconds not supported
        #https://bitbucket.org/nielsenb/aniso8601/issues/10/sub-microsecond-precision-in-durations-is
        #https://bitbucket.org/nielsenb/aniso8601/issues/13/parsing-of-leap-second-gives-wildly
        with self.assertRaises(LeapSecondError):
            parse_time('23:59:60')

        with self.assertRaises(LeapSecondError):
            parse_time('23:59:60Z')

        with self.assertRaises(LeapSecondError):
            parse_time('23:59:60+00:00')

        #Leap seconds not supported, but exception type should be changed
        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:60')

        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:60Z')

        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:60+00:00')

        #Seconds must not be greater than or equal to 60
        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:61')

        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:61Z')

        with self.assertRaises(SecondsOutOfBoundsError):
            parse_time('00:00:61+00:00')

        #Minutes must not be greater than 60
        with self.assertRaises(MinutesOutOfBoundsError):
            parse_time('00:61')

        with self.assertRaises(MinutesOutOfBoundsError):
            parse_time('00:61Z')

        with self.assertRaises(MinutesOutOfBoundsError):
            parse_time('00:61+00:00')
Exemplo n.º 21
0
    def test_parse_time(self):
        time = parse_time('01:23:45')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)

        time = parse_time('24:00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)

        time = parse_time('23:21:28.512400')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)

        time = parse_time('01:23')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)

        time = parse_time('24:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)

        time = parse_time('01:23.4567')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)

        time = parse_time('012345')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)

        time = parse_time('240000')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)

        time = parse_time('0123')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)

        time = parse_time('2400')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)

        time = parse_time('01')
        self.assertEqual(time.hour, 1)

        time = parse_time('24')
        self.assertEqual(time.hour, 0)

        time = parse_time('232128.512400+00:00')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('0123.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 27)
        self.assertEqual(time.second, 24)
        self.assertEqual(time.microsecond, 120000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23:45+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 45)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00:00+00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        self.assertEqual(time.second, 0)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+00:00')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('24:00+00:00')
        self.assertEqual(time.hour, 0)
        self.assertEqual(time.minute, 0)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('01:23.4567+00:00')
        self.assertEqual(time.hour, 1)
        self.assertEqual(time.minute, 23)
        self.assertEqual(time.second, 27)
        self.assertEqual(time.microsecond, 402000)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), '+00:00')

        time = parse_time('23:21:28.512400+11:15')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=11, minutes=15))
        self.assertEqual(tzinfoobject.tzname(None), '+11:15')

        time = parse_time('23:21:28.512400-12:34')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), -datetime.timedelta(hours=12, minutes=34))
        self.assertEqual(tzinfoobject.tzname(None), '-12:34')

        time = parse_time('23:21:28.512400Z')
        self.assertEqual(time.hour, 23)
        self.assertEqual(time.minute, 21)
        self.assertEqual(time.second, 28)
        self.assertEqual(time.microsecond, 512400)
        tzinfoobject = time.tzinfo
        self.assertEqual(tzinfoobject.utcoffset(None), datetime.timedelta(hours=0))
        self.assertEqual(tzinfoobject.tzname(None), 'UTC')
Exemplo n.º 22
0
    def test_parse_time(self):
        testtuples = (('01:23:45', {'hh': '01', 'mm': '23',
                                    'ss': '45', 'tz': None}),
                      ('24:00:00', {'hh': '24', 'mm': '00',
                                    'ss': '00', 'tz': None}),
                      ('23:21:28.512400', {'hh': '23', 'mm': '21',
                                           'ss': '28.512400', 'tz': None}),
                      ('14:43:59.9999997', {'hh': '14', 'mm': '43',
                                            'ss': '59.9999997', 'tz': None}),
                      ('01:23', {'hh': '01', 'mm': '23', 'tz': None}),
                      ('24:00', {'hh': '24', 'mm': '00', 'tz': None}),
                      ('01:23.4567', {'hh': '01', 'mm': '23.4567',
                                      'tz': None}),
                      ('012345', {'hh': '01', 'mm': '23',
                                  'ss': '45', 'tz': None}),
                      ('240000', {'hh': '24', 'mm': '00',
                                  'ss': '00', 'tz': None}),
                      ('144359.9999997', {'hh': '14', 'mm': '43',
                                          'ss': '59.9999997', 'tz': None}),
                      ('0123', {'hh': '01', 'mm': '23', 'tz': None}),
                      ('2400', {'hh': '24', 'mm': '00', 'tz': None}),
                      ('01', {'hh': '01', 'tz': None}),
                      ('24', {'tz': None}),
                      ('12.5', {'hh': '12.5', 'tz': None}),
                      ('232128.512400+00:00', {'hh': '23', 'mm': '21',
                                               'ss': '28.512400',
                                               'tz': (False, None,
                                                      '00', '00',
                                                      '+00:00', 'timezone')}),
                      ('0123.4567+00:00', {'hh': '01', 'mm': '23.4567',
                                           'tz': (False, None,
                                                  '00', '00',
                                                  '+00:00', 'timezone')}),
                      ('01.4567+00:00', {'hh': '01.4567',
                                         'tz': (False, None,
                                                '00', '00',
                                                '+00:00', 'timezone')}),
                      ('01:23:45+00:00', {'hh': '01', 'mm': '23',
                                          'ss': '45',
                                          'tz': (False, None,
                                                 '00', '00',
                                                 '+00:00', 'timezone')}),
                      ('24:00:00+00:00', {'hh': '24', 'mm': '00',
                                          'ss': '00',
                                          'tz': (False, None,
                                                 '00', '00',
                                                 '+00:00', 'timezone')}),
                      ('23:21:28.512400+00:00', {'hh': '23', 'mm': '21',
                                                 'ss': '28.512400',
                                                 'tz': (False, None,
                                                        '00', '00',
                                                        '+00:00',
                                                        'timezone')}),
                      ('01:23+00:00', {'hh': '01', 'mm': '23',
                                       'tz': (False, None,
                                              '00', '00',
                                              '+00:00', 'timezone')}),
                      ('24:00+00:00', {'hh': '24', 'mm': '00',
                                       'tz': (False, None,
                                              '00', '00',
                                              '+00:00', 'timezone')}),
                      ('01:23.4567+00:00', {'hh': '01', 'mm': '23.4567',
                                            'tz': (False, None,
                                                   '00', '00',
                                                   '+00:00', 'timezone')}),
                      ('23:21:28.512400+11:15', {'hh': '23', 'mm': '21',
                                                 'ss': '28.512400',
                                                 'tz': (False, None,
                                                        '11', '15',
                                                        '+11:15',
                                                        'timezone')}),
                      ('23:21:28.512400-12:34', {'hh': '23', 'mm': '21',
                                                 'ss': '28.512400',
                                                 'tz': (True, None,
                                                        '12', '34',
                                                        '-12:34',
                                                        'timezone')}),
                      ('23:21:28.512400Z', {'hh': '23', 'mm': '21',
                                            'ss': '28.512400',
                                            'tz': (False, True,
                                                   None, None,
                                                   'Z', 'timezone')}),
                      ('06:14:00.000123Z', {'hh': '06', 'mm': '14',
                                            'ss': '00.000123',
                                            'tz': (False, True,
                                                   None, None,
                                                   'Z', 'timezone')}))

        for testtuple in testtuples:
            with mock.patch.object(aniso8601.builder.PythonTimeBuilder,
                                   'build_time') as mockBuildTime:

                mockBuildTime.return_value = testtuple[1]

                result = parse_time(testtuple[0])

                self.assertEqual(result, testtuple[1])
                mockBuildTime.assert_called_once_with(**testtuple[1])
Exemplo n.º 23
0
    def test_parse_time_badtype(self):
        testtuples = (None, 1, False, 1.234)

        for testtuple in testtuples:
            with self.assertRaises(ValueError):
                parse_time(testtuple, builder=None)